1 // Copyright Cromwell D. Enage 2017.
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 #include <boost/parameter/config.hpp>
7
8 #if (BOOST_PARAMETER_MAX_ARITY < 10)
9 #error Define BOOST_PARAMETER_MAX_ARITY as 10 or greater.
10 #endif
11
12 #include <boost/parameter.hpp>
13
14 namespace test {
15
16 BOOST_PARAMETER_NAME(in(lrc0))
17 BOOST_PARAMETER_NAME(out(lr0))
18 BOOST_PARAMETER_NAME(in(rrc0))
19 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
20 BOOST_PARAMETER_NAME(consume(rr0))
21 #else
22 BOOST_PARAMETER_NAME(rr0)
23 #endif
24 BOOST_PARAMETER_NAME(in(lrc1))
25 BOOST_PARAMETER_NAME(out(lr1))
26 BOOST_PARAMETER_NAME(in(rrc1))
27 BOOST_PARAMETER_NAME(in(lrc2))
28 BOOST_PARAMETER_NAME(out(lr2))
29 BOOST_PARAMETER_NAME(rr2)
30
31 struct g_parameters
32 : boost::parameter::parameters<
33 boost::parameter::required<test::tag::lrc0>
34 , boost::parameter::required<test::tag::lr0>
35 , boost::parameter::required<test::tag::rrc0>
36 , boost::parameter::required<test::tag::rr0>
37 , boost::parameter::required<test::tag::lrc1>
38 , boost::parameter::required<test::tag::lr1>
39 , boost::parameter::required<test::tag::rrc1>
40 , boost::parameter::optional<test::tag::lrc2>
41 , boost::parameter::optional<test::tag::lr2>
42 , boost::parameter::optional<test::tag::rr2>
43 >
44 {
45 };
46 } // namespace test
47
48 #include <boost/parameter/macros.hpp>
49 #include <boost/core/lightweight_test.hpp>
50 #include "evaluate_category.hpp"
51
52 namespace test {
53
54 struct C
55 {
56 BOOST_PARAMETER_MEMFUN(static int, evaluate, 7, 10, g_parameters)
57 {
58 BOOST_TEST_EQ(
59 test::passed_by_lvalue_reference_to_const
60 , U::evaluate_category<0>(p[test::_lrc0])
61 );
62 BOOST_TEST_EQ(
63 test::passed_by_lvalue_reference
64 , U::evaluate_category<0>(p[test::_lr0])
65 );
66 BOOST_TEST_EQ(
67 test::passed_by_lvalue_reference_to_const
68 , U::evaluate_category<1>(p[test::_lrc1])
69 );
70 BOOST_TEST_EQ(
71 test::passed_by_lvalue_reference
72 , U::evaluate_category<1>(p[test::_lr1])
73 );
74 BOOST_TEST_EQ(
75 test::passed_by_lvalue_reference_to_const
76 , U::evaluate_category<2>(
77 p[test::_lrc2 | test::lvalue_const_bitset<2>()]
78 )
79 );
80 BOOST_TEST_EQ(
81 test::passed_by_lvalue_reference
82 , U::evaluate_category<2>(
83 p[test::_lr2 || test::lvalue_bitset_function<2>()]
84 )
85 );
86 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
87 BOOST_TEST_EQ(
88 test::passed_by_rvalue_reference_to_const
89 , U::evaluate_category<0>(p[test::_rrc0])
90 );
91 BOOST_TEST_EQ(
92 test::passed_by_rvalue_reference
93 , U::evaluate_category<0>(p[test::_rr0])
94 );
95 BOOST_TEST_EQ(
96 test::passed_by_rvalue_reference_to_const
97 , U::evaluate_category<1>(p[test::_rrc1])
98 );
99 BOOST_TEST_EQ(
100 test::passed_by_rvalue_reference
101 , U::evaluate_category<2>(
102 p[test::_rr2 || test::rvalue_bitset_function<2>()]
103 )
104 );
105 #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
106 BOOST_TEST_EQ(
107 test::passed_by_lvalue_reference_to_const
108 , U::evaluate_category<0>(p[test::_rrc0])
109 );
110 BOOST_TEST_EQ(
111 test::passed_by_lvalue_reference_to_const
112 , U::evaluate_category<0>(p[test::_rr0])
113 );
114 BOOST_TEST_EQ(
115 test::passed_by_lvalue_reference_to_const
116 , U::evaluate_category<1>(p[test::_rrc1])
117 );
118 BOOST_TEST_EQ(
119 test::passed_by_lvalue_reference_to_const
120 , U::evaluate_category<2>(
121 p[test::_rr2 || test::rvalue_bitset_function<2>()]
122 )
123 );
124 #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
125
126 return 0;
127 }
128 };
129 } // namespace test
130
131 #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
132 #include <boost/core/ref.hpp>
133 #endif
134
main()135 int main()
136 {
137 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \
138 (10 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY)
139 test::C::evaluate(
140 test::lvalue_const_bitset<0>()
141 , test::lvalue_bitset<0>()
142 , test::rvalue_const_bitset<0>()
143 , test::rvalue_bitset<0>()
144 , test::lvalue_const_bitset<1>()
145 , test::lvalue_bitset<1>()
146 , test::rvalue_const_bitset<1>()
147 );
148 test::C::evaluate(
149 test::lvalue_const_bitset<0>()
150 , test::lvalue_bitset<0>()
151 , test::rvalue_const_bitset<0>()
152 , test::rvalue_bitset<0>()
153 , test::lvalue_const_bitset<1>()
154 , test::lvalue_bitset<1>()
155 , test::rvalue_const_bitset<1>()
156 , test::lvalue_const_bitset<2>()
157 , test::lvalue_bitset<2>()
158 , test::rvalue_bitset<2>()
159 );
160 #else // no perfect forwarding support and no exponential overloads
161 test::C::evaluate(
162 test::lvalue_const_bitset<0>()
163 , boost::ref(test::lvalue_bitset<0>())
164 , test::rvalue_const_bitset<0>()
165 , test::rvalue_bitset<0>()
166 , test::lvalue_const_bitset<1>()
167 , boost::ref(test::lvalue_bitset<1>())
168 , test::rvalue_const_bitset<1>()
169 );
170 test::C::evaluate(
171 test::lvalue_const_bitset<0>()
172 , boost::ref(test::lvalue_bitset<0>())
173 , test::rvalue_const_bitset<0>()
174 , test::rvalue_bitset<0>()
175 , test::lvalue_const_bitset<1>()
176 , boost::ref(test::lvalue_bitset<1>())
177 , test::rvalue_const_bitset<1>()
178 , test::lvalue_const_bitset<2>()
179 , boost::ref(test::lvalue_bitset<2>())
180 , test::rvalue_bitset<2>()
181 );
182 #endif // perfect forwarding support, or exponential overloads
183 return boost::report_errors();
184 }
185
186