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)
9 #ifndef BOOST_CLBL_TRTS_FUNCTION_TYPE_HPP
10 #define BOOST_CLBL_TRTS_FUNCTION_TYPE_HPP
12 #include <boost/callable_traits/detail/core.hpp>
14 namespace boost { namespace callable_traits {
17 /*`[section:ref_function_type function_type]
19 ``#include <boost/callable_traits/function_type.hpp>``
24 using function_type_t = //see below
26 detail::try_but_fail_if_invalid<typename detail::traits<
27 detail::shallow_decay<T>>::function_type,
28 cannot_determine_parameters_for_this_type>;
32 template<typename T, typename = std::false_type>
33 struct function_type_impl {};
36 struct function_type_impl <T, typename std::is_same<
37 function_type_t<T>, detail::dummy>::type>
39 using type = function_type_t<T>;
46 struct function_type : detail::function_type_impl<T> {};
49 }} // namespace boost::callable_traits
54 * `T` must be one of the following:
58 * member function pointer
60 * user-defined type with a non-overloaded `operator()`
61 * type of a non-generic lambda
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.
73 [heading Input/Output Examples]
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)]]
90 [heading Example Program]
91 [import ../example/function_type.cpp]