1// Copyright Cromwell D. Enage 2019.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_RETURN_TYPE_HPP
7#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_RETURN_TYPE_HPP
8
9namespace boost { namespace parameter { namespace aux {
10
11 // A metafunction that transforms void(*)(T) -> identity<T>
12 template <typename UnaryFunctionPointer>
13 struct unaryfunptr_return_type;
14}}} // namespace boost::parameter::aux
15
16#include <boost/parameter/config.hpp>
17
18#if defined(BOOST_PARAMETER_CAN_USE_MP11)
19#include <boost/mp11/utility.hpp>
20#else
21#include <boost/mpl/identity.hpp>
22#endif
23
24namespace boost { namespace parameter { namespace aux {
25
26 template <typename Arg>
27 struct unaryfunptr_return_type<void(*)(Arg)>
28 {
29#if defined(BOOST_PARAMETER_CAN_USE_MP11)
30 using type = ::boost::mp11::mp_identity<Arg>;
31#else
32 typedef ::boost::mpl::identity<Arg> type;
33#endif
34 };
35
36 template <>
37 struct unaryfunptr_return_type<void(*)(void)>
38 {
39#if defined(BOOST_PARAMETER_CAN_USE_MP11)
40 using type = ::boost::mp11::mp_identity<void>;
41#else
42 typedef ::boost::mpl::identity<void> type;
43#endif
44 };
45}}} // namespace boost::parameter::aux
46
47#if !defined(BOOST_NO_SFINAE)
48#include <boost/core/enable_if.hpp>
49
50namespace boost { namespace parameter { namespace aux {
51
52 template <typename Pred, typename Ret>
53 struct unaryfunptr_return_type<void(*)(::boost::enable_if<Pred,Ret>)>
54 {
55 typedef ::boost::enable_if<Pred,Ret> type;
56 };
57
58 template <bool b, typename Ret>
59 struct unaryfunptr_return_type<void(*)(::boost::enable_if_c<b,Ret>)>
60 {
61 typedef ::boost::enable_if_c<b,Ret> type;
62 };
63
64 template <typename Pred, typename Ret>
65 struct unaryfunptr_return_type<void(*)(::boost::lazy_enable_if<Pred,Ret>)>
66 {
67 typedef ::boost::lazy_enable_if<Pred,Ret> type;
68 };
69
70 template <bool b, typename Ret>
71 struct unaryfunptr_return_type<void(*)(::boost::lazy_enable_if_c<b,Ret>)>
72 {
73 typedef ::boost::lazy_enable_if_c<b,Ret> type;
74 };
75
76 template <typename Pred, typename Ret>
77 struct unaryfunptr_return_type<void(*)(::boost::disable_if<Pred,Ret>)>
78 {
79 typedef ::boost::disable_if<Pred,Ret> type;
80 };
81
82 template <bool b, typename Ret>
83 struct unaryfunptr_return_type<void(*)(::boost::disable_if_c<b,Ret>)>
84 {
85 typedef ::boost::disable_if_c<b,Ret> type;
86 };
87
88 template <typename B, typename Ret>
89 struct unaryfunptr_return_type<void(*)(::boost::lazy_disable_if<B,Ret>)>
90 {
91 typedef ::boost::lazy_disable_if<B,Ret> type;
92 };
93
94 template <bool b, typename Ret>
95 struct unaryfunptr_return_type<void(*)(::boost::lazy_disable_if_c<b,Ret>)>
96 {
97 typedef ::boost::lazy_disable_if_c<b,Ret> type;
98 };
99}}} // namespace boost::parameter::aux
100
101#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
102#include <type_traits>
103
104namespace boost { namespace parameter { namespace aux {
105
106 template <bool b, typename Ret>
107 struct unaryfunptr_return_type<void(*)(::std::enable_if<b,Ret>)>
108 {
109 typedef ::std::enable_if<b,Ret> type;
110 };
111}}} // namespace boost::parameter::aux
112
113#endif // BOOST_NO_CXX11_HDR_TYPE_TRAITS
114#endif // BOOST_NO_SFINAE
115
116// A macro that takes a parenthesized C++ type name (T) and transforms it
117// into an un-parenthesized type expression equivalent to identity<T>.
118#define BOOST_PARAMETER_PARENTHESIZED_RETURN_TYPE(x) \
119 ::boost::parameter::aux::unaryfunptr_return_type< void(*)x >::type
120
121#endif // include guard
122
123

source code of boost/libs/parameter/include/boost/parameter/aux_/preprocessor/impl/parenthesized_return_type.hpp