is_reference_member.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_REFERENCE_MEMBER_HPP
  7. #define BOOST_CLBL_TRTS_IS_REFERENCE_MEMBER_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ is_reference_member_hpp
  11. /*`[section:ref_is_reference_member is_reference_member]
  12. [heading Header]
  13. ``#include <boost/callable_traits/is_reference_member.hpp>``
  14. [heading Definition]
  15. */
  16. // inherits from either std::true_type or std::false_type
  17. template<typename T>
  18. struct is_reference_member;
  19. //<-
  20. template<typename T>
  21. struct is_reference_member : detail::traits<
  22. detail::shallow_decay<T>>::is_reference_member {
  23. using type = typename detail::traits<
  24. detail::shallow_decay<T>>::is_reference_member;
  25. };
  26. #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
  27. template<typename T>
  28. struct is_reference_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_reference_member_v = //see below
  40. //<-
  41. detail::traits<detail::shallow_decay<T>>::is_reference_member::value;
  42. #endif
  43. }} // namespace boost::callable_traits
  44. //->
  45. /*`
  46. [heading Constraints]
  47. * none
  48. [heading Behavior]
  49. * `is_reference_member<T>::value` is `true` when either:
  50. * `T` is a function type with a '&' or '&&' member qualifier
  51. * `T` is a pointer to a member function with a '&' or '&&' member qualifiers
  52. * `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a '&' or '&&' member qualifier
  53. * On compilers that support variable templates, `is_reference_member_v<T>` is equivalent to `is_reference_member<T>::value`.
  54. [heading Input/Output Examples]
  55. [table
  56. [[`T`] [`is_reference_member_v<T>`]]
  57. [[`int() &`] [`true`]]
  58. [[`int() const &&`] [`true`]]
  59. [[`int(foo::* const)() &&`] [`true`]]
  60. [[`int(foo::*)(...) volatile &`] [`true`]]
  61. [[`int() const`] [`false`]]
  62. [[`int() volatile`] [`false`]]
  63. [[`int(foo::*)() const`] [`false`]]
  64. [[`int() const`] [`false`]]
  65. [[`int() volatile`] [`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_reference_member.cpp]
  73. [is_reference_member]
  74. [endsect]
  75. */
  76. //]
  77. #endif // #ifndef BOOST_CLBL_TRTS_IS_REFERENCE_MEMBER_HPP