is_volatile_member.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. *
  3. @Copyright Barrett Adair 2015-2017
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_CLBL_TRTS_IS_VOLATILE_MEMBER_HPP
  8. #define BOOST_CLBL_TRTS_IS_VOLATILE_MEMBER_HPP
  9. #include <boost/callable_traits/detail/core.hpp>
  10. namespace boost { namespace callable_traits {
  11. //[ is_volatile_member_hpp
  12. /*`[section:ref_is_volatile_member is_volatile_member]
  13. [heading Header]
  14. ``#include <boost/callable_traits/is_volatile_member.hpp>``
  15. [heading Definition]
  16. */
  17. // inherits from either std::true_type or std::false_type
  18. template<typename T>
  19. struct is_volatile_member;
  20. //<-
  21. template<typename T>
  22. struct is_volatile_member : detail::traits<
  23. detail::shallow_decay<T>>::is_volatile_member {
  24. using type = typename detail::traits<
  25. detail::shallow_decay<T>>::is_volatile_member;
  26. };
  27. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  28. template<typename T>
  29. struct is_volatile_member_v {
  30. static_assert(std::is_same<T, detail::dummy>::value,
  31. "Variable templates not supported on this compiler.");
  32. };
  33. #else
  34. //->
  35. // only available when variable templates are supported
  36. template<typename T>
  37. //<-
  38. BOOST_CLBL_TRAITS_INLINE_VAR
  39. //->
  40. constexpr bool is_volatile_member_v = //see below
  41. //<-
  42. detail::traits<detail::shallow_decay<T>>::is_volatile_member::value;
  43. #endif
  44. }} // namespace boost::callable_traits
  45. //->
  46. /*`
  47. [heading Constraints]
  48. * none
  49. [heading Behavior]
  50. * `is_volatile_member<T>::value` is `true` when either:
  51. * `T` is a function type with a `volatile` member qualifier
  52. * `T` is a pointer to a member function with a `volatile` member qualifier
  53. * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a `volatile` member qualifier
  54. * On compilers that support variable templates, `is_volatile_member_v<T>` is equivalent to `is_volatile_member<T>::value`.
  55. [heading Input/Output Examples]
  56. [table
  57. [[`T`] [`is_volatile_member_v<T>`]]
  58. [[`int() volatile`] [`true`]]
  59. [[`int() const volatile`] [`true`]]
  60. [[`int() volatile &&`] [`true`]]
  61. [[`int(foo::*)() volatile`] [`true`]]
  62. [[`int(foo::* const)() volatile`] [`true`]]
  63. [[`int(foo::*)() const volatile`] [`true`]]
  64. [[`int(foo::*)() const volatile &&`][`true`]]
  65. [[`int()`] [`false`]]
  66. [[`int() const`] [`false`]]
  67. [[`int() &&`] [`false`]]
  68. [[`int(*)()`] [`false`]]
  69. [[`int`] [`false`]]
  70. [[`int foo::*`] [`false`]]
  71. [[`volatile int foo::*`] [`false`]]
  72. ]
  73. [heading Example Program]
  74. [import ../example/is_volatile_member.cpp]
  75. [is_volatile_member]
  76. [endsect]
  77. */
  78. //]
  79. #endif // #ifndef BOOST_CLBL_TRTS_IS_VOLATILE_MEMBER_HPP