apply_return.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_RETURN_HPP
10 #define BOOST_CLBL_TRTS_APPLY_RETURN_HPP
11 
13 
14 namespace boost { namespace callable_traits {
15 
17 BOOST_CLBL_TRTS_SFINAE_MSG(apply_return, invalid_types_for_apply_return)
18 
19 namespace detail {
20 
21  template<typename T, typename R>
24  };
25 
26  //special case
27  template<typename... Args, typename R>
28  struct apply_return_helper<std::tuple<Args...>, R> {
29  using type = R(Args...);
30  };
31 }
32 
33 //[ apply_return_hpp
34 /*`
35 [section:ref_apply_return apply_return]
36 [heading Header]
37 ``#include <boost/callable_traits/apply_return.hpp>``
38 [heading Definition]
39 */
40 
41 template<typename T, typename R>
42 using apply_return_t = //see below
43 //<-
46  invalid_types_for_apply_return>;
47 
48 namespace detail {
49 
50  template<typename T, typename R, typename = std::false_type>
51  struct apply_return_impl {};
52 
53  template<typename T, typename R>
54  struct apply_return_impl <T, R, typename std::is_same<
55  apply_return_t<T, R>, detail::dummy>::type>
56  {
58  };
59 }
60  //->
61 
62 template<typename T, typename R>
64 
65 //<-
66 }} // namespace boost::callable_traits
67 //->
68 
69 /*`
70 [heading Constraints]
71 * `T` must one of the following:
72  * `std::tuple` template instantiation
73  * function
74  * function pointer
75  * function reference
76  * member function pointer
77  * member data pointer
78 * If `T` is a pointer, it may not be cv/ref qualified
79 
80 [heading Behavior]
81 * When `T` is `std::tuple<Args...>`, the aliased type is `R(Args...)`.
82 * When `T` is a function, function pointer, function reference, or member function pointer, the aliased type's return type is `R`, but is otherwise identical to `T`.
83 * When `T` is a member data pointer of class `foo` to a `U` type (such that `T` is `U foo::*`), the aliased type is `R foo::*`.
84 
85 [heading Input/Output Examples]
86 [table
87  [[`T`] [`apply_return_t<T, float>`]]
88  [[`std::tuple<int, int>`] [`float(int, int)`]]
89  [[`int()`] [`float()`]]
90  [[`int (&)()`] [`float(&)()`]]
91  [[`int (*)()`] [`float(*)()`]]
92  [[`int (*)(...)`] [`float(*)()`]]
93  [[`int(foo::*)()`] [`float(foo::*)()`]]
94  [[`int(foo::*)() &`] [`float(foo::*)() &`]]
95  [[`int(foo::*)() &&`] [`float(foo::*)() &&`]]
96  [[`int(foo::*)() const`] [`float(foo::*)() const`]]
97  [[`int(foo::*)() transaction_safe`] [`float(foo::*)() transaction_safe`]]
98  [[`int foo::*`] [`float foo::*`]]
99  [[`int`] [(substitution failure)]]
100  [[`int (*const)()`] [(substitution failure)]]
101 ]
102 
103 [heading Example Program]
104 [/import ../example/apply_return.cpp]
105 [apply_return]
106 [endsect]
107 */
108 //]
109 #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 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::apply_return_helper< T, R >::type, invalid_types_for_apply_return > apply_return_t
#define BOOST_CLBL_TRTS_SFINAE_MSG(origin, name)
#define BOOST_CLBL_TRTS_DEFINE_SFINAE_ERROR_ORIGIN(origin)
typename detail::traits< T >::template apply_return< R > type