args.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_ARGS_HPP
10 #define BOOST_CLBL_TRTS_ARGS_HPP
11 
13 
14 namespace boost { namespace callable_traits {
15 
16 //[ args_hpp
17 /*`[section:ref_args args]
18 [heading Header]
19 ``#include <boost/callable_traits/args.hpp>``
20 [heading Definition]
21 */
22 
23 template<typename T, template<class...> class Container = std::tuple>
24 using args_t = //see below
25 //<-
27  typename detail::traits<
28  detail::shallow_decay<T>>::template expand_args<Container>,
29  cannot_expand_the_parameter_list_of_first_template_argument>;
30 
31 namespace detail {
32 
33  template<typename T, template<class...> class Container,
34  typename = std::false_type>
35  struct args_impl {};
36 
37  template<typename T, template<class...> class Container>
38  struct args_impl <T, Container, typename std::is_same<
39  args_t<T, Container>, detail::dummy>::type>
40  {
42  };
43 }
44 
45 //->
46 
47 template<typename T,
48  template<class...> class Container = std::tuple>
49 struct args : detail::args_impl<T, Container> {};
50 
51 //<-
52 }} // namespace boost::callable_traits
53 //->
54 
55 /*`
56 [heading Constraints]
57 * `T` must be one of the following:
58  * function
59  * function pointer
60  * function reference
61  * member function pointer
62  * member data pointer
63  * user-defined type with a non-overloaded `operator()`
64  * type of a non-generic lambda
65 
66 [heading Behavior]
67 * When the constraints are violated, a substitution failure occurs.
68 * When `T` is a function, function pointer, or function reference, the aliased type is `Container` instantiated with the function's parameter types.
69 * When `T` is a function object, the aliased type is `Container` instantiated with the `T::operator()` parameter types.
70 * When `T` is a member function pointer, the aliased type is a `Container` instantiation, where the first type argument is a reference to the parent class of `T`, qualified according to the member qualifiers on `T`, such that the first type is equivalent to `boost::callable_traits::qualified_class_of_t<T>`. The subsequent type arguments, if any, are the parameter types of the member function.
71 * When `T` is a member data pointer, the aliased type is `Container` with a single element, which is a `const` reference to the parent class of `T`.
72 
73 [heading Input/Output Examples]
74 [table
75  [[`T`] [`args_t<T>`]]
76  [[`void(float, char, int)`] [`std::tuple<float, char, int>`]]
77  [[`void(*)(float, char, int)`] [`std::tuple<float, char, int`]]
78  [[`void(&)(float, char, int)`] [`std::tuple<float, char, int`]]
79  [[`void(float, char, int) const &&`][`std::tuple<float, char, int>`]]
80  [[`void(*)()`] [`std::tuple<>`]]
81  [[`void(foo::* const &)(float, char, int)`] [`std::tuple<foo&, float, char, int>`]]
82  [[`int(foo::*)(int) const`] [`std::tuple<const foo&, int>`]]
83  [[`void(foo::*)() volatile &&`] [`std::tuple<volatile foo &&>`]]
84  [[`int foo::*`] [`std::tuple<const foo&>`]]
85  [[`const int foo::*`] [`std::tuple<const foo&>`]]
86  [[`int`] [(substitution failure)]]
87  [[`int (*const)()`] [(substitution failure)]]
88 ]
89 
90 [heading Example Program]
91 [import ../example/args.cpp]
92 [args]
93 [endsect]
94 */
95 //]
96 
97 #endif // #ifndef BOOST_CLBL_TRTS_ARGS_HPP
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 > >::template expand_args< Container >, cannot_expand_the_parameter_list_of_first_template_argument > args_t
Definition: args.hpp:29