1 // Copyright Daniel Wallin 2006.
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)
6 #ifndef BOOST_PARAMETER_VALUE_TYPE_060921_HPP
7 #define BOOST_PARAMETER_VALUE_TYPE_060921_HPP
9 #include <boost/parameter/aux_/void.hpp>
10 #include <boost/parameter/config.hpp>
12 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
13 #include <boost/mp11/integral.hpp>
14 #include <boost/mp11/list.hpp>
15 #include <boost/mp11/utility.hpp>
16 #include <type_traits>
18 #include <boost/mpl/bool.hpp>
19 #include <boost/mpl/if.hpp>
20 #include <boost/mpl/eval_if.hpp>
21 #include <boost/mpl/identity.hpp>
22 #include <boost/mpl/apply_wrap.hpp>
23 #include <boost/mpl/assert.hpp>
24 #include <boost/type_traits/is_same.hpp>
27 namespace boost { namespace parameter {
29 // A metafunction that, given an argument pack, returns the value type
30 // of the parameter identified by the given keyword. If no such parameter
31 // has been specified, returns Default
33 template <typename Parameters, typename Keyword, typename Default>
36 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
37 using type = ::boost::mp11::mp_apply_q<
38 typename Parameters::binding
39 , ::boost::mp11::mp_list<Keyword,Default,::boost::mp11::mp_false>
44 ::std::is_same<Default,::boost::parameter::void_>
45 , ::boost::mp11::mp_if<
46 ::std::is_same<type,::boost::parameter::void_>
47 , ::boost::mp11::mp_false
48 , ::boost::mp11::mp_true
50 , ::boost::mp11::mp_true
52 , "required parameters must not result in void_ type"
54 #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
55 typedef typename ::boost::mpl::apply_wrap3<
56 typename Parameters::binding
59 , ::boost::mpl::false_
63 typename ::boost::mpl::eval_if<
64 ::boost::is_same<Default,::boost::parameter::void_>
66 ::boost::is_same<type,::boost::parameter::void_>
67 , ::boost::mpl::false_
73 #endif // BOOST_PARAMETER_CAN_USE_MP11
76 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
77 template <typename Placeholder, typename Keyword, typename Default>
80 using type = ::boost::mp11::mp_apply_q<
82 , ::boost::mp11::mp_list<Keyword,Default,::boost::mp11::mp_false>
87 ::std::is_same<Default,::boost::parameter::void_>
88 , ::boost::mp11::mp_if<
89 ::std::is_same<type,::boost::parameter::void_>
90 , ::boost::mp11::mp_false
91 , ::boost::mp11::mp_true
93 , ::boost::mp11::mp_true
95 , "required parameters must not result in void_ type"
98 #endif // BOOST_PARAMETER_CAN_USE_MP11
99 }} // namespace boost::parameter
101 #include <boost/parameter/aux_/is_placeholder.hpp>
103 namespace boost { namespace parameter {
108 , typename Default = ::boost::parameter::void_
111 #if !defined(BOOST_PARAMETER_CAN_USE_MP11)
112 : ::boost::mpl::eval_if<
113 ::boost::parameter::aux::is_mpl_placeholder<Parameters>
114 , ::boost::mpl::identity<int>
115 , ::boost::parameter::value_type0<Parameters,Keyword,Default>
119 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
120 using type = typename ::boost::mp11::mp_if<
121 ::boost::parameter::aux::is_mpl_placeholder<Parameters>
122 , ::boost::mp11::mp_identity<int>
123 , ::boost::mp11::mp_if<
124 ::boost::parameter::aux::is_mp11_placeholder<Parameters>
125 , ::boost::parameter::value_type1<Parameters,Keyword,Default>
126 , ::boost::parameter::value_type0<Parameters,Keyword,Default>
131 }} // namespace boost::parameter
133 #include <boost/parameter/aux_/result_of0.hpp>
135 namespace boost { namespace parameter {
137 // A metafunction that, given an argument pack, returns the value type
138 // of the parameter identified by the given keyword. If no such parameter
139 // has been specified, returns the type returned by invoking DefaultFn
140 template <typename Parameters, typename Keyword, typename DefaultFn>
141 struct lazy_value_type
143 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
144 using type = ::boost::mp11::mp_apply_q<
145 typename Parameters::binding
146 , ::boost::mp11::mp_list<
148 , typename ::boost::parameter::aux::result_of0<DefaultFn>::type
149 , ::boost::mp11::mp_false
153 typedef typename ::boost::mpl::apply_wrap3<
154 typename Parameters::binding
156 , typename ::boost::parameter::aux::result_of0<DefaultFn>::type
157 , ::boost::mpl::false_
159 #endif // BOOST_PARAMETER_CAN_USE_MP11
161 }} // namespace boost::parameter
163 #endif // include guard