1 // Copyright David Abrahams, Daniel Wallin 2003.
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_AUX_PACK_DEDUCE_TAG_HPP
7 #define BOOST_PARAMETER_AUX_PACK_DEDUCE_TAG_HPP
9 namespace boost { namespace parameter { namespace aux {
13 , typename ArgumentPack
14 , typename DeducedArgs
17 , typename EmitsErrors
20 }}} // namespace boost::parameter::aux
22 #include <boost/parameter/aux_/lambda_tag.hpp>
23 #include <boost/parameter/config.hpp>
24 #include <boost/mpl/apply_wrap.hpp>
25 #include <boost/mpl/lambda.hpp>
27 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
29 namespace boost { namespace parameter { namespace aux {
31 template <typename Predicate, typename Argument, typename ArgumentPack>
32 struct deduce_tag_condition_mpl
33 : ::boost::mpl::apply_wrap2<
34 typename ::boost::mpl::lambda<
36 , ::boost::parameter::aux::lambda_tag
43 }}} // namespace boost::parameter::aux
45 #include <boost/parameter/aux_/has_nested_template_fn.hpp>
46 #include <boost/mp11/list.hpp>
47 #include <boost/mp11/utility.hpp>
49 namespace boost { namespace parameter { namespace aux {
51 template <typename Predicate, typename Argument, typename ArgumentPack>
52 struct deduce_tag_condition_mp11
54 using type = ::boost::mp11::mp_apply_q<
56 , ::boost::mp11::mp_list<Argument,ArgumentPack>
60 template <typename Predicate, typename Argument, typename ArgumentPack>
61 using deduce_tag_condition = ::boost::mp11::mp_if<
62 ::boost::parameter::aux::has_nested_template_fn<Predicate>
63 , ::boost::parameter::aux
64 ::deduce_tag_condition_mp11<Predicate,Argument,ArgumentPack>
65 , ::boost::parameter::aux
66 ::deduce_tag_condition_mpl<Predicate,Argument,ArgumentPack>
68 }}} // namespace boost::parameter::aux
71 #include <boost/mpl/bool.hpp>
72 #include <boost/mpl/if.hpp>
73 #include <boost/mpl/eval_if.hpp>
74 #include <boost/mpl/assert.hpp>
75 #endif // BOOST_PARAMETER_CAN_USE_MP11
77 #include <boost/parameter/aux_/set.hpp>
78 #include <boost/parameter/aux_/pack/tag_type.hpp>
79 #include <boost/parameter/aux_/pack/tag_deduced.hpp>
81 namespace boost { namespace parameter { namespace aux {
83 // Helper for deduce_tag<...>, below.
86 , typename ArgumentPack
87 , typename DeducedArgs
90 , typename EmitsErrors
94 typedef typename DeducedArgs::spec _spec;
96 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
97 typedef typename ::boost::parameter::aux::deduce_tag_condition<
98 typename _spec::predicate
100 typedef typename ::boost::mpl::apply_wrap2<
101 typename ::boost::mpl::lambda<
102 typename _spec::predicate
103 , ::boost::parameter::aux::lambda_tag
110 #if !defined(BOOST_PARAMETER_CAN_USE_MP11)
111 // Deduced parameter matches several arguments.
113 typename ::boost::mpl::eval_if<
114 typename ::boost::parameter::aux::has_key_<
116 , typename ::boost::parameter::aux::tag_type<_spec>::type
118 , ::boost::mpl::eval_if<
122 , ::boost::mpl::false_
123 , ::boost::mpl::true_
125 , ::boost::mpl::true_
127 , ::boost::mpl::true_
130 #endif // BOOST_PARAMETER_CAN_USE_MP11
133 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
134 using type = typename ::boost::mp11::mp_if<
136 typedef typename ::boost::mpl::eval_if<
139 , ::boost::parameter::aux
140 ::tag_deduced<UsedArgs,_spec,Argument,TagFn>
141 , ::boost::parameter::aux::deduce_tag<
144 , typename DeducedArgs::tail
149 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
155 }}} // namespace boost::parameter::aux
157 #include <boost/parameter/aux_/void.hpp>
159 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
160 #include <type_traits>
162 #include <boost/mpl/pair.hpp>
163 #include <boost/type_traits/is_same.hpp>
166 namespace boost { namespace parameter { namespace aux {
168 // Tries to deduced a keyword tag for a given Argument.
169 // Returns an mpl::pair<> consisting of the tagged_argument<>,
170 // and an mpl::set<> where the new tag has been inserted.
172 // Argument: The argument type to be tagged.
174 // ArgumentPack: The ArgumentPack built so far.
176 // DeducedArgs: A specialization of deduced_item<> (see below).
177 // A list containing only the deduced ParameterSpecs.
179 // UsedArgs: An mpl::set<> containing the keyword tags used so far.
181 // TagFn: A metafunction class used to tag positional or deduced
182 // arguments with a keyword tag.
185 , typename ArgumentPack
186 , typename DeducedArgs
189 , typename EmitsErrors
192 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
193 : ::boost::mp11::mp_if<
194 ::std::is_same<DeducedArgs,::boost::parameter::void_>
195 , ::boost::mp11::mp_identity<
196 ::boost::mp11::mp_list< ::boost::parameter::void_,UsedArgs>
199 : ::boost::mpl::eval_if<
200 ::boost::is_same<DeducedArgs,::boost::parameter::void_>
201 , ::boost::mpl::pair< ::boost::parameter::void_,UsedArgs>
203 , ::boost::parameter::aux::deduce_tag0<
214 }}} // namespace boost::parameter::aux
216 #endif // include guard