apply_member_pointer.hpp
Go to the documentation of this file.
1 /*
2 
3 @Copyright Barrett Adair 2015-2017
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
6 
7 */
8 
9 #ifndef BOOST_CLBL_TRTS_APPLY_MEMBER_POINTER_HPP
10 #define BOOST_CLBL_TRTS_APPLY_MEMBER_POINTER_HPP
11 
13 
14 namespace boost { namespace callable_traits {
15 
17 BOOST_CLBL_TRTS_SFINAE_MSG(apply_member_pointer, members_cannot_have_a_type_of_void)
18 BOOST_CLBL_TRTS_SFINAE_MSG(apply_member_pointer, second_template_argument_must_be_a_class_or_struct)
19 
20 namespace detail {
21 
22  template<typename T, typename C, bool = std::is_class<C>::value>
24 
25  template<typename T, typename C>
26  struct make_member_pointer<T, C, true> {
27  using type = typename std::remove_reference<T>::type C::*;
28  };
29 
30  template<typename C>
31  struct make_member_pointer<void, C, true> {
32  using type = invalid_type;
33  };
34 
35  template<typename T, typename C>
36  struct make_member_pointer<T, C, false> {
38  };
39 
40  template<typename T, typename C>
42 }
43 
44 //[ apply_member_pointer_hpp
45 /*`
46 [section:ref_apply_member_pointer apply_member_pointer]
47 [heading Header]
48 ``#include <boost/callable_traits/apply_member_pointer.hpp>``
49 [heading Definition]
50 */
51 
52 template<typename T, typename C>
53 using apply_member_pointer_t = //see below
54 //<-
59 
61 
63  second_template_argument_must_be_a_class_or_struct> >;
64 
65 namespace detail {
66 
67  template<typename T, typename C, typename = std::false_type>
69 
70  template<typename T, typename C>
71  struct apply_member_pointer_impl <T, C, typename std::is_same<
72  apply_member_pointer_t<T, C>, detail::dummy>::type>
73  {
75  };
76 }
77 
78 //->
79 
80 template<typename T, typename C>
82 
83 //<-
84 }} // namespace boost::callable_traits
85 //->
86 
87 /*`
88 [heading Constraints]
89 * `T` may be any type except `void`
90 * `C` must be a user-defined type
91 
92 [heading Behavior]
93 * A substitution failure occurs if the constraints are violated.
94 * When `T` is a function, function pointer (unqualified), or function reference, then the aliased type is a member function pointer of `C` with the same parameters and return type.
95 * When `T` is a member function pointer (unqualified) of any type, the aliased type is a member function pointer of `C` with the same parameters and return type.
96 * Otherwise, the aliased type is a member data pointer equivalent to `std::remove_reference_t<T> C::*`.
97 
98 [heading Input/Output Examples]
99 [table
100  [[`T`] [`apply_member_pointer_t<T, foo>`]]
101  [[`int()`] [`int(foo::*)()`]]
102  [[`int (&)()`] [`int(foo::*)()`]]
103  [[`int (*)()`] [`int(foo::*)()`]]
104  [[`int(bar::*)()`] [`int(foo::*)()`]]
105  [[`int(bar::*)() &`] [`int(foo::*)() &`]]
106  [[`int(bar::*)() &&`] [`int(foo::*)() &&`]]
107  [[`int(bar::*)() const`] [`int(foo::*)() const`]]
108  [[`int(bar::*)() transaction_safe`] [`int(foo::*)() transaction_safe`]]
109  [[`int bar::*`] [`int foo::*`]]
110  [[`int`] [`int foo::*`]]
111  [[`int &`] [`int foo::*`]]
112  [[`const int &`] [`const int foo::*`]]
113  [[`int (*const)()`] [`int (*const foo::*)()`]]
114  [[`void`] [(substitution failure)]]
115 ]
116 
117 [heading Example Program]
118 [import ../example/apply_member_pointer.cpp]
119 [apply_member_pointer]
120 [endsect]
121 */
122 //]
123 #endif
typename std::conditional< std::is_reference< T >::value, reference_error, invalid_type >::type error_type
Definition: utility.hpp:28
typename std::conditional< std::is_same< T, invalid_type >::value, Fallback, T >::type fallback_if_invalid
Definition: utility.hpp:70
typename BOOST_CLBL_TRTS_DISJUNCTION(function_object< unwrap_reference< T > >, function< T >, pmf< T >, pmd< T >, default_callable_traits< T >)::traits traits
Definition: traits.hpp:25
typename make_member_pointer< T, C >::type make_member_pointer_t
typename BOOST_CLBL_TRTS_DISJUNCTION(FailIfs..., success< T >)::_::type sfinae_try
detail::sfinae_try< detail::fallback_if_invalid< typename detail::traits< T >::template apply_member_pointer< C >, typename detail::make_member_pointer< T, C >::type >, detail::fail_when_same< void, T, members_cannot_have_a_type_of_void >, detail::fail_if<!std::is_class< C >::value, second_template_argument_must_be_a_class_or_struct > > apply_member_pointer_t
#define BOOST_CLBL_TRTS_SFINAE_MSG(origin, name)
#define BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(origin)