qualified_class_of.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_QUALIFIED_class_of_HPP
  7. #define BOOST_CLBL_TRTS_QUALIFIED_class_of_HPP
  8. #include <boost/callable_traits/detail/core.hpp>
  9. namespace boost { namespace callable_traits {
  10. //[ qualified_class_of_hpp
  11. /*`
  12. [section:ref_qualified_class_of qualified_class_of]
  13. [heading Header]
  14. ``#include <boost/callable_traits/qualified_class_of.hpp>``
  15. [heading Definition]
  16. */
  17. template<typename T>
  18. using qualified_class_of_t = //see below
  19. //<-
  20. detail::try_but_fail_if_invalid<
  21. typename detail::traits<detail::shallow_decay<T>>::invoke_type,
  22. type_is_not_a_member_pointer>;
  23. namespace detail {
  24. template<typename T, typename = std::false_type>
  25. struct qualified_class_of_impl {};
  26. template<typename T>
  27. struct qualified_class_of_impl <T, typename std::is_same<
  28. qualified_class_of_t<T>, detail::dummy>::type>
  29. {
  30. using type = qualified_class_of_t<T>;
  31. };
  32. }
  33. //->
  34. template<typename T>
  35. struct qualified_class_of : detail::qualified_class_of_impl<T> {};
  36. //<-
  37. }} // namespace boost::callable_traits
  38. //->
  39. /*`
  40. [heading Constraints]
  41. * `T` must be a member pointer
  42. [heading Behavior]
  43. * A substitution failure occurs if the constraints are violated.
  44. * If `T` is a member function pointer, the aliased type is the parent class of the member, qualified according to the member qualifiers on `T`. If `T` does not have a member reference qualifier, then the aliased type will be an lvalue reference.
  45. * If `T` is a member data pointer, the aliased type is equivalent to `ct::class_of<T> const &`.
  46. [heading Input/Output Examples]
  47. [table
  48. [[`T`] [`qualified_class_of_t<T>`]]
  49. [[`void(foo::*)()`] [`foo &`]]
  50. [[`void(foo::* volatile)() const`] [`foo const &`]]
  51. [[`void(foo::*)() &&`] [`foo &&`]]
  52. [[`void(foo::*&)() volatile &&`] [`foo volatile &&`]]
  53. [[`int foo::*`] [`foo const &`]]
  54. [[`const int foo::*`] [`foo const &`]]
  55. ]
  56. [heading Example Program]
  57. [import ../example/qualified_class_of.cpp]
  58. [qualified_class_of]
  59. [endsect]
  60. */
  61. //]
  62. #endif // #ifndef BOOST_CLBL_TRTS_QUALIFIED_class_of_HPP