• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3 @Copyright Barrett Adair 2015-2017
4 
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
7 
8 */
9 
10 #ifndef BOOST_CLBL_TRTS_QUALIFIED_class_of_HPP
11 #define BOOST_CLBL_TRTS_QUALIFIED_class_of_HPP
12 
13 #include <boost/callable_traits/detail/core.hpp>
14 
15 namespace boost { namespace callable_traits {
16 
17 //[ qualified_class_of_hpp
18 /*`
19 [section:ref_qualified_class_of qualified_class_of]
20 [heading Header]
21 ``#include <boost/callable_traits/qualified_class_of.hpp>``
22 [heading Definition]
23 */
24 
25 template<typename T>
26 using qualified_class_of_t = //see below
27 //<-
28     detail::try_but_fail_if_invalid<
29         typename detail::traits<detail::shallow_decay<T>>::invoke_type,
30         type_is_not_a_member_pointer>;
31 
32 namespace detail {
33 
34     template<typename T, typename = std::false_type>
35     struct qualified_class_of_impl {};
36 
37     template<typename T>
38     struct qualified_class_of_impl <T, typename std::is_same<
39         qualified_class_of_t<T>, detail::dummy>::type>
40     {
41         using type = qualified_class_of_t<T>;
42     };
43 }
44 
45 //->
46 
47 template<typename T>
48 struct qualified_class_of : detail::qualified_class_of_impl<T> {};
49 
50 //<-
51 }} // namespace boost::callable_traits
52 //->
53 
54 /*`
55 [heading Constraints]
56 * `T` must be a member pointer
57 
58 [heading Behavior]
59 * A substitution failure occurs if the constraints are violated.
60 * 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.
61 * If `T` is a member data pointer, the aliased type is equivalent to `ct::class_of<T> const &`.
62 
63 [heading Input/Output Examples]
64 [table
65     [[`T`]                              [`qualified_class_of_t<T>`]]
66     [[`void(foo::*)()`]                 [`foo &`]]
67     [[`void(foo::* volatile)() const`]           [`foo const &`]]
68     [[`void(foo::*)() &&`]              [`foo &&`]]
69     [[`void(foo::*&)() volatile &&`]     [`foo volatile &&`]]
70     [[`int foo::*`]                     [`foo const &`]]
71     [[`const int foo::*`]               [`foo const &`]]
72 ]
73 
74 [heading Example Program]
75 [import ../example/qualified_class_of.cpp]
76 [qualified_class_of]
77 [endsect]
78 */
79 //]
80 
81 #endif // #ifndef BOOST_CLBL_TRTS_QUALIFIED_class_of_HPP
82