function_type.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_FUNCTION_TYPE_HPP
10 #define BOOST_CLBL_TRTS_FUNCTION_TYPE_HPP
11 
13 
14 namespace boost { namespace callable_traits {
15 
16 //[ function_type_hpp
17 /*`[section:ref_function_type function_type]
18 [heading Header]
19 ``#include <boost/callable_traits/function_type.hpp>``
20 [heading Definition]
21 */
22 
23 template<typename T>
24 using function_type_t = //see below
25 //<-
28  cannot_determine_parameters_for_this_type>;
29 
30 namespace detail {
31 
32  template<typename T, typename = std::false_type>
33  struct function_type_impl {};
34 
35  template<typename T>
36  struct function_type_impl <T, typename std::is_same<
37  function_type_t<T>, detail::dummy>::type>
38  {
40  };
41 }
42 
43 //->
44 
45 template<typename T>
47 
48 //<-
49 }} // namespace boost::callable_traits
50 //->
51 
52 /*`
53 [heading Constraints]
54 * `T` must be one of the following:
55  * function
56  * function pointer
57  * function reference
58  * member function pointer
59  * member data pointer
60  * user-defined type with a non-overloaded `operator()`
61  * type of a non-generic lambda
62 
63 [heading Behavior]
64 * When the constraints are violated, a substitution failure occurs.
65 * When `T` is a function, the aliased type is identical to `T`, except that the aliased function type will not have member qualifiers or the `transaction_safe` specifier.
66 * When `T` is a function pointer, the aliased type is equivalent to `std::remove_pointer_t<T>`.
67 * When `T` is a function reference, the aliased type is equivalent to `std::remove_reference_t<T>`.
68 * When `T` is a function object, the aliased type is a function type with the same return type and parameter list as `T`'s `operator()`.
69 * When `T` is a member function pointer, the aliased type is a function type with the same return type as `T`, and the first parameter is a reference to the parent class of `T`, qualified according to the member qualifiers on `T`. The subsequent parameters, if any, are the parameter types of `T`.
70 * When `T` is a member data pointer, the aliased type is a function type returning the underlying member type of `T`, taking a single parameter, which is a `const` reference to the parent type of `T`.
71 * In all cases, the aliased function type will not have member qualifiers, and will not have the `transaction_safe` specifier.
72 
73 [heading Input/Output Examples]
74 [table
75  [[`T`] [`function_type_t<T>`]]
76  [[`void(int)`] [`void(int)`]]
77  [[`void(int) const`] [`void(int)`]]
78  [[`void(int) transaction_safe`] [`void(int)`]]
79  [[`void(*const &)(int)`] [`void(int)`]]
80  [[`void(&)(int)`] [`void(int)`]]
81  [[`void(* volatile)()`] [`void()`]]
82  [[`int(foo::*)(int)`] [`int(foo&, int)`]]
83  [[`int(foo::*)(int) const`] [`int(const foo&, int)`]]
84  [[`void(foo::*)() volatile &&`] [`void(volatile foo&&)`]]
85  [[`int foo::*`] [`int(const foo&)`]]
86  [[`const int foo::*`] [`int(const foo&)`]]
87  [[`int`] [(substitution failure)]]
88 ]
89 
90 [heading Example Program]
91 [import ../example/function_type.cpp]
92 [function_type]
93 [endsect]
94 */
95 //]
96 
97 #endif
sfinae_try< T, fail_when_same< U, invalid_type, ErrorType >, fail_when_same< U, reference_error, reference_type_not_supported_by_this_metafunction > > try_but_fail_if_invalid
Definition: utility.hpp:58
typename std::remove_cv< typename std::remove_reference< T >::type >::type shallow_decay
Definition: utility.hpp:79
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
detail::try_but_fail_if_invalid< typename detail::traits< detail::shallow_decay< T > >::function_type, cannot_determine_parameters_for_this_type > function_type_t