add_member_volatile.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. @Copyright Barrett Adair 2015-2017
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef BOOST_CLBL_TRTS_ADD_MEMBER_VOLATILE_HPP
  7. #define BOOST_CLBL_TRTS_ADD_MEMBER_VOLATILE_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ add_member_volatile_hpp
  11. /*`
  12. [section:ref_add_member_volatile add_member_volatile]
  13. [heading Header]
  14. ``#include <boost/callable_traits/add_member_volatile.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using add_member_volatile_t = //see below
  19. //<-
  20. #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  21. detail::sfinae_try<
  22. typename detail::traits<T>::add_member_volatile,
  23. detail::fail_when_same<typename detail::traits<T>::add_member_volatile,
  24. detail::abominable_functions_not_supported_on_this_compiler,
  25. this_compiler_doesnt_support_abominable_function_types>,
  26. detail::fail_if_invalid<
  27. typename detail::traits<T>::add_member_volatile,
  28. member_qualifiers_are_illegal_for_this_type>>;
  29. #else
  30. detail::try_but_fail_if_invalid<
  31. typename detail::traits<T>::add_member_volatile,
  32. member_qualifiers_are_illegal_for_this_type>;
  33. #endif // #ifdef BOOST_CLBL_TRTS_DISABLE_ABOMINABLE_FUNCTIONS
  34. namespace detail {
  35. template<typename T, typename = std::false_type>
  36. struct add_member_volatile_impl {};
  37. template<typename T>
  38. struct add_member_volatile_impl <T, typename std::is_same<
  39. add_member_volatile_t<T>, detail::dummy>::type>
  40. {
  41. using type = add_member_volatile_t<T>;
  42. };
  43. }
  44. //->
  45. template<typename T>
  46. struct add_member_volatile : detail::add_member_volatile_impl<T> {};
  47. //<-
  48. }} // namespace boost::callable_traits
  49. //->
  50. /*`
  51. [heading Constraints]
  52. * `T` must be a function type or a member function pointer type
  53. * If `T` is a pointer, it may not be cv/ref qualified
  54. [heading Behavior]
  55. * A substitution failure occurs if the constraints are violated.
  56. * Adds a member volatile qualifier to `T`, if not already present.
  57. [heading Input/Output Examples]
  58. [table
  59. [[`T`] [`add_member_volatile_t<T>`]]
  60. [[`int()`] [`int() volatile`]]
  61. [[`int(foo::*)()`] [`int(foo::*)() volatile`]]
  62. [[`int(foo::*)() &`] [`int(foo::*)() volatile &`]]
  63. [[`int(foo::*)() &&`] [`int(foo::*)() volatile &&`]]
  64. [[`int(foo::*)() const`] [`int(foo::*)() const volatile`]]
  65. [[`int(foo::*)() transaction_safe`] [`int(foo::*)() volatile transaction_safe`]]
  66. [[`int`] [(substitution failure)]]
  67. [[`int (&)()`] [(substitution failure)]]
  68. [[`int (*)()`] [(substitution failure)]]
  69. [[`int foo::*`] [(substitution failure)]]
  70. [[`int (foo::* const)()`] [(substitution failure)]]
  71. ]
  72. [heading Example Program]
  73. [import ../example/add_member_volatile.cpp]
  74. [add_member_volatile]
  75. [endsect][/section:ref_add_member_volatile]
  76. */
  77. //]
  78. #endif