is_cv_member.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_IS_CV_MEMBER_HPP
  7. #define BOOST_CLBL_TRTS_IS_CV_MEMBER_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ is_cv_member_hpp
  11. /*`[section:ref_is_cv_member is_cv_member]
  12. [heading Header]
  13. ``#include <boost/callable_traits/is_cv_member.hpp>``
  14. [heading Definition]
  15. */
  16. // inherits from either std::true_type or std::false_type
  17. template<typename T>
  18. struct is_cv_member;
  19. //<-
  20. template<typename T>
  21. struct is_cv_member
  22. : detail::traits<detail::shallow_decay<T>>::is_cv_member {
  23. using type = typename detail::traits<
  24. detail::shallow_decay<T>>::is_cv_member;
  25. };
  26. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  27. template<typename T>
  28. struct is_cv_member_v {
  29. static_assert(std::is_same<T, detail::dummy>::value,
  30. "Variable templates not supported on this compiler.");
  31. };
  32. #else
  33. //->
  34. // only available when variable templates are supported
  35. template<typename T>
  36. //<-
  37. BOOST_CLBL_TRAITS_INLINE_VAR
  38. //->
  39. constexpr bool is_cv_member_v = //see below
  40. //<-
  41. detail::traits<detail::shallow_decay<T>>::is_cv_member::value;
  42. #endif
  43. }} // namespace boost::callable_traits
  44. //->
  45. /*`
  46. [heading Constraints]
  47. * none
  48. [heading Behavior]
  49. * `is_cv_member<T>::value` is `true` when either:
  50. * `T` is a function type with both `const` and `volatile` member qualifiers
  51. * `T` is a pointer to a member function with both `const` and `volatile` member qualifiers
  52. * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has both `const` and `volatile` member qualifiers
  53. * On compilers that support variable templates, `is_cv_member_v<T>` is equivalent to `is_cv_member<T>::value`.
  54. [heading Input/Output Examples]
  55. [table
  56. [[`T`] [`is_cv_member_v<T>`]]
  57. [[`int() const volatile`] [`true`]]
  58. [[`int() const volatile &`] [`true`]]
  59. [[`int(foo::* const &)() const volatile`] [`true`]]
  60. [[`int() const`] [`false`]]
  61. [[`int() volatile`] [`false`]]
  62. [[`int(foo::*)() const`] [`false`]]
  63. [[`int() const`] [`false`]]
  64. [[`int() volatile`] [`false`]]
  65. [[`int() &&`] [`false`]]
  66. [[`int(*)()`] [`false`]]
  67. [[`int`] [`false`]]
  68. [[`int foo::*`] [`false`]]
  69. [[`const int foo::*`] [`false`]]
  70. ]
  71. [heading Example Program]
  72. [import ../example/is_cv_member.cpp]
  73. [is_cv_member]
  74. [endsect]
  75. */
  76. //]
  77. #endif // #ifndef BOOST_CLBL_TRTS_IS_CV_MEMBER_HPP