]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/callable_traits/function_type.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / callable_traits / function_type.hpp
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
12 #include <boost/callable_traits/detail/core.hpp>
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 //<-
26 detail::try_but_fail_if_invalid<typename detail::traits<
27 detail::shallow_decay<T>>::function_type,
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 {
39 using type = function_type_t<T>;
40 };
41 }
42
43 //->
44
45 template<typename T>
46 struct function_type : detail::function_type_impl<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