has_member_qualifiers.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_HAS_MEMBER_QUALIFIERS_HPP
  7. #define BOOST_CLBL_TRTS_HAS_MEMBER_QUALIFIERS_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ has_member_qualifiers_hpp
  11. /*`[section:ref_has_member_qualifiers has_member_qualifiers]
  12. [heading Header]
  13. ``#include <boost/callable_traits/has_member_qualifiers.hpp>``
  14. [heading Definition]
  15. */
  16. // inherits from either std::true_type or std::false_type
  17. template<typename T>
  18. struct has_member_qualifiers;
  19. //<-
  20. template<typename T>
  21. struct has_member_qualifiers : detail::traits<
  22. detail::shallow_decay<T>>::has_member_qualifiers {
  23. using type = typename detail::traits<
  24. detail::shallow_decay<T>>::has_member_qualifiers;
  25. };
  26. // older compilers don't support variable templates
  27. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  28. template<typename T>
  29. struct has_member_qualifiers_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 has_member_qualifiers_v = //see below
  41. //<-
  42. detail::traits<detail::shallow_decay<T>>::has_member_qualifiers::value;
  43. #endif
  44. }} // namespace boost::callable_traits
  45. //->
  46. /*`
  47. [heading Constraints]
  48. * none
  49. [heading Behavior]
  50. * `std::false_type` is inherited by `has_member_qualifiers<T>` and is aliased by `typename has_member_qualifiers<T>::type`, except when one of the following criteria is met, in which case `std::true_type` would be similarly inherited and aliased:
  51. * `T` is a function with member qualifiers
  52. * `T` is a member function pointer with member qualifiers
  53. * `T` is a function object with a member-qualified `operator()`
  54. * On compilers that support variable templates, `has_member_qualifiers_v<T>` is equivalent to `has_member_qualifiers<T>::value`.
  55. [heading Input/Output Examples]
  56. [table
  57. [[`T`] [`has_member_qualifiers_v<T>`]]
  58. [[`void() const`] [`true`]]
  59. [[`void() const transaction_safe`] [`true`]]
  60. [[`void() volatile &&`] [`true`]]
  61. [[`int(foo::*)() &`] [`true`]]
  62. [[`void(foo::*)() const`] [`true`]]
  63. [[`void(foo::*&)() const`] [`true`]]
  64. [[`void(foo::* const)() const`] [`true`]]
  65. [[`void()`] [`false`]]
  66. [[`void() transaction_safe`] [`false`]]
  67. [[`void(*)()`] [`false`]]
  68. [[`void(*&)()`] [`false`]]
  69. [[`int`] [`false`]]
  70. [[`const int`] [`false`]]
  71. [[`int foo::*`] [`false`]]
  72. [[`const int foo::*`] [`false`]]
  73. ]
  74. [heading Example Program]
  75. [import ../example/has_member_qualifiers.cpp]
  76. [has_member_qualifiers]
  77. [endsect]
  78. */
  79. //]
  80. #endif //BOOST_CLBL_TRTS_HAS_MEMBER_QUALIFIERS_HPP