1 // Copyright Cromwell D. Enage 2018.
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_AUGMENT_PREDICATE_HPP
7 #define BOOST_PARAMETER_AUGMENT_PREDICATE_HPP
9 #include <boost/parameter/keyword_fwd.hpp>
10 #include <boost/mpl/bool.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/mpl/eval_if.hpp>
13 #include <boost/type_traits/is_lvalue_reference.hpp>
14 #include <boost/type_traits/is_scalar.hpp>
15 #include <boost/type_traits/is_same.hpp>
17 namespace boost { namespace parameter { namespace aux {
19 template <typename V, typename R, typename Tag>
20 struct augment_predicate_check_consume_ref
21 : ::boost::mpl::eval_if<
24 , ::boost::mpl::eval_if<
26 typename Tag::qualifier
27 , ::boost::parameter::consume_reference
30 ::boost::is_lvalue_reference<R>
31 , ::boost::mpl::false_
39 }}} // namespace boost::parameter::aux
41 #include <boost/type_traits/is_const.hpp>
43 namespace boost { namespace parameter { namespace aux {
45 template <typename V, typename R, typename Tag>
46 struct augment_predicate_check_out_ref
47 : ::boost::mpl::eval_if<
49 typename Tag::qualifier
50 , ::boost::parameter::out_reference
52 , ::boost::mpl::eval_if<
53 ::boost::is_lvalue_reference<R>
56 , ::boost::mpl::false_
59 , ::boost::mpl::false_
65 }}} // namespace boost::parameter::aux
67 #include <boost/parameter/aux_/lambda_tag.hpp>
68 #include <boost/mpl/apply_wrap.hpp>
69 #include <boost/mpl/lambda.hpp>
71 namespace boost { namespace parameter { namespace aux {
80 class augment_predicate
82 typedef typename ::boost::mpl::lambda<
84 , ::boost::parameter::aux::lambda_tag
85 >::type _actual_predicate;
88 typedef typename ::boost::mpl::eval_if<
89 typename ::boost::mpl::if_<
90 ::boost::parameter::aux
91 ::augment_predicate_check_consume_ref<T,R,Tag>
92 , ::boost::parameter::aux
93 ::augment_predicate_check_out_ref<T,R,Tag>
94 , ::boost::mpl::false_
96 , ::boost::mpl::apply_wrap2<_actual_predicate,T,Args>
97 , ::boost::mpl::false_
100 }}} // namespace boost::parameter::aux
102 #include <boost/parameter/config.hpp>
104 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
105 #include <boost/mp11/integral.hpp>
106 #include <boost/mp11/utility.hpp>
107 #include <type_traits>
109 namespace boost { namespace parameter { namespace aux {
111 template <typename V, typename R, typename Tag>
112 using augment_predicate_check_consume_ref_mp11 = ::boost::mp11::mp_if<
114 , ::boost::mp11::mp_true
115 , ::boost::mp11::mp_if<
117 typename Tag::qualifier
118 , ::boost::parameter::consume_reference
120 , ::boost::mp11::mp_if<
121 ::std::is_lvalue_reference<R>
122 , ::boost::mp11::mp_false
123 , ::boost::mp11::mp_true
125 , boost::mp11::mp_true
129 template <typename V, typename R, typename Tag>
130 using augment_predicate_check_out_ref_mp11 = ::boost::mp11::mp_if<
132 typename Tag::qualifier
133 , ::boost::parameter::out_reference
135 , ::boost::mp11::mp_if<
136 ::std::is_lvalue_reference<R>
137 , ::boost::mp11::mp_if<
139 , ::boost::mp11::mp_false
140 , ::boost::mp11::mp_true
142 , ::boost::mp11::mp_false
144 , ::boost::mp11::mp_true
146 }}} // namespace boost::parameter::aux
148 #include <boost/mp11/list.hpp>
150 namespace boost { namespace parameter { namespace aux {
159 struct augment_predicate_mp11_impl
161 using type = ::boost::mp11::mp_if<
162 ::boost::mp11::mp_if<
163 ::boost::parameter::aux
164 ::augment_predicate_check_consume_ref_mp11<T,R,Tag>
165 , ::boost::parameter::aux
166 ::augment_predicate_check_out_ref_mp11<T,R,Tag>
167 , ::boost::mp11::mp_false
170 ::mp_apply_q<Predicate,::boost::mp11::mp_list<T,Args> >
171 , ::boost::mp11::mp_false
174 }}} // namespace boost::parameter::aux
176 #include <boost/parameter/aux_/has_nested_template_fn.hpp>
178 namespace boost { namespace parameter { namespace aux {
187 using augment_predicate_mp11 = ::boost::mp11::mp_if<
188 ::boost::parameter::aux::has_nested_template_fn<Predicate>
189 , ::boost::parameter::aux
190 ::augment_predicate_mp11_impl<Predicate,R,Tag,T,Args>
191 , ::boost::parameter::aux
192 ::augment_predicate<Predicate,R,Tag,T,Args>
194 }}} // namespace boost::parameter::aux
196 #endif // BOOST_PARAMETER_CAN_USE_MP11
197 #endif // include guard