deduced.hpp
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright David Abrahams, Daniel Wallin 2003.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PARAMETER_DEDUCED_HPP
#define BOOST_PARAMETER_DEDUCED_HPP
#include <boost/parameter/aux_/use_default.hpp>
namespace boost { namespace parameter {
// This metafunction can be used to describe the treatment of particular
// named parameters for the purposes of overload elimination with SFINAE,
// by placing specializations in the parameters<...> list.
//
// If a keyword k is specified with deduced<...>, that keyword
// will be automatically deduced from the argument list.
template <typename Tag>
struct deduced
{
typedef Tag key_type;
};
}}
#include <boost/parameter/config.hpp>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/integral.hpp>
#else
#include <boost/mpl/bool.hpp>
#endif
namespace boost { namespace parameter { namespace aux {
template <typename T>
struct is_deduced_aux
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
: ::boost::mp11::mp_false
#else
: ::boost::mpl::false_
#endif
{
};
template <typename Tag>
struct is_deduced_aux< ::boost::parameter::deduced<Tag> >
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
: ::boost::mp11::mp_true
#else
: ::boost::mpl::true_
#endif
{
};
template <typename T>
struct is_deduced0
: ::boost::parameter::aux::is_deduced_aux<typename T::key_type>::type
{
};
}}} // namespace boost::parameter::aux
#include <boost/parameter/required.hpp>
#include <boost/parameter/optional.hpp>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/utility.hpp>
#else
#include <boost/mpl/if.hpp>
#endif
namespace boost { namespace parameter { namespace aux {
//
// tag_type, has_default, and predicate --
//
// These metafunctions accept a ParameterSpec and extract the
// keyword tag, whether or not a default is supplied for the
// parameter, and the predicate that the corresponding actual
// argument type is required match.
//
// a ParameterSpec is a specialization of either keyword<...>,
// required<...>, optional<...>
//
template <typename T>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
using has_default = ::boost::mp11::mp_if<
::boost::parameter::aux::is_required<T>
, ::boost::mp11::mp_false
, ::boost::mp11::mp_true
>;
#else
struct has_default
: ::boost::mpl::if_<
::boost::parameter::aux::is_required<T>
, ::boost::mpl::false_
, ::boost::mpl::true_
>::type
{
};
#endif
template <typename T>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
using is_deduced = ::boost::mp11::mp_if<
::boost::mp11::mp_if<
::boost::parameter::aux::is_optional<T>
, ::boost::mp11::mp_true
, ::boost::parameter::aux::is_required<T>
>
, ::boost::parameter::aux::is_deduced0<T>
, ::boost::mp11::mp_false
>;
#else
struct is_deduced
: ::boost::mpl::if_<
typename ::boost::mpl::if_<
::boost::parameter::aux::is_optional<T>
, ::boost::mpl::true_
, ::boost::parameter::aux::is_required<T>
>::type
, ::boost::parameter::aux::is_deduced0<T>
, ::boost::mpl::false_
>::type
{
};
#endif // BOOST_PARAMETER_CAN_USE_MP11
}}} // namespace boost::parameter::aux
#endif // include guard