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