]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/parameter/test/normalized_argument_types.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / parameter / test / normalized_argument_types.cpp
CommitLineData
92f5a8d4
TL
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)
7c673cae 5
92f5a8d4 6#include <boost/parameter/config.hpp>
7c673cae 7
92f5a8d4
TL
8#if (BOOST_PARAMETER_MAX_ARITY < 2)
9#error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater.
10#endif
11#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
12 (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 3)
13#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
14as 3 or greater.
15#endif
7c673cae 16
92f5a8d4 17namespace test {
7c673cae 18
92f5a8d4 19 struct count_instances
7c673cae 20 {
92f5a8d4
TL
21 count_instances()
22 {
23 ++count_instances::count;
24 }
7c673cae 25
92f5a8d4
TL
26 count_instances(count_instances const&)
27 {
28 ++count_instances::count;
29 }
30
31 template <typename T>
32 count_instances(T const&)
33 {
34 ++count_instances::count;
35 }
36
37 ~count_instances()
38 {
39 --count_instances::count;
40 }
41
42 static std::size_t count;
43
44 void noop() const
45 {
46 }
47 };
48
49 std::size_t count_instances::count = 0;
50} // namespace test
51
52#include <boost/parameter/name.hpp>
53
54namespace test {
55
56 BOOST_PARAMETER_NAME(x)
57 BOOST_PARAMETER_NAME(y)
58} // namespace test
7c673cae 59
92f5a8d4 60#include <boost/parameter/preprocessor.hpp>
7c673cae 61
92f5a8d4
TL
62#if defined(BOOST_PARAMETER_CAN_USE_MP11)
63#include <type_traits>
64#else
65#include <boost/mpl/bool.hpp>
66#include <boost/mpl/if.hpp>
67#include <boost/mpl/assert.hpp>
68#include <boost/type_traits/is_convertible.hpp>
69#endif
7c673cae 70
92f5a8d4 71namespace test {
7c673cae 72
92f5a8d4
TL
73 BOOST_PARAMETER_FUNCTION((int), f, tag,
74 (required
75 (x, (long))
76 )
77 (optional
78 (y, (long), 2L)
79 )
7c673cae 80 )
92f5a8d4
TL
81 {
82#if defined(BOOST_PARAMETER_CAN_USE_MP11)
83 static_assert(
84 std::is_convertible<x_type,long>::value
85 , "is_convertible<x_type,long>"
86 );
87 static_assert(
88 std::is_convertible<y_type,long>::value
89 , "is_convertible<y_type,long>"
90 );
91#else
92 BOOST_MPL_ASSERT((
93 typename boost::mpl::if_<
94 boost::is_convertible<x_type,long>
95 , boost::mpl::true_
96 , boost::mpl::false_
97 >::type
98 ));
99 BOOST_MPL_ASSERT((
100 typename boost::mpl::if_<
101 boost::is_convertible<y_type,long>
102 , boost::mpl::true_
103 , boost::mpl::false_
104 >::type
105 ));
106#endif // BOOST_PARAMETER_CAN_USE_MP11
107 return 0;
108 }
109} // namespace test
7c673cae 110
92f5a8d4
TL
111#include <boost/core/lightweight_test.hpp>
112
113namespace test {
114
115 BOOST_PARAMETER_FUNCTION((int), g, tag,
116 (required
117 (x, (test::count_instances))
118 )
7c673cae 119 )
92f5a8d4
TL
120 {
121#if defined(BOOST_PARAMETER_CAN_USE_MP11)
122 static_assert(
123 std::is_convertible<x_type,test::count_instances>::value
124 , "is_convertible<x_type,test::count_instances>"
125 );
126#else
127 BOOST_MPL_ASSERT((
128 typename boost::mpl::if_<
129 boost::is_convertible<x_type,test::count_instances>
130 , boost::mpl::true_
131 , boost::mpl::false_
132 >::type
133 ));
134#endif
135 x.noop();
136#if !BOOST_WORKAROUND(BOOST_GCC, < 40000)
137 BOOST_TEST_LT(0, test::count_instances::count);
138#endif
139 return 0;
140 }
7c673cae 141
92f5a8d4
TL
142 BOOST_PARAMETER_FUNCTION((int), h, tag,
143 (required
144 (x, (test::count_instances const&))
145 )
7c673cae 146 )
92f5a8d4
TL
147 {
148#if defined(BOOST_PARAMETER_CAN_USE_MP11)
149 static_assert(
150 std::is_convertible<x_type,test::count_instances const>::value
151 , "is_convertible<x_type,test::count_instances const>"
152 );
153#else
154 BOOST_MPL_ASSERT((
155 typename boost::mpl::if_<
156 boost::is_convertible<x_type,test::count_instances const>
157 , boost::mpl::true_
158 , boost::mpl::false_
159 >::type
160 ));
161#endif
162 x.noop();
163#if !BOOST_WORKAROUND(BOOST_GCC, < 40000)
164 BOOST_TEST_EQ(1, test::count_instances::count);
165#endif
166 return 0;
167 }
168} // namespace test
7c673cae
FG
169
170int main()
171{
92f5a8d4
TL
172 test::f(1, 2);
173 test::f(1., 2.f);
174 test::f(1U);
175 test::g(0);
176 test::h(0);
177 return boost::report_errors();
7c673cae
FG
178}
179