]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/earwicker.cpp
bump version to 19.2.0-pve1
[ceph.git] / ceph / src / boost / libs / parameter / test / earwicker.cpp
1 // Copyright David Abrahams, Daniel Wallin 2005.
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 < 4)
9 #error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater.
10 #endif
11 #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
12 (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5)
13 #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
14 as 5 or greater.
15 #endif
16
17 #include <boost/parameter/name.hpp>
18
19 namespace test {
20
21 BOOST_PARAMETER_NAME(w)
22 BOOST_PARAMETER_NAME(x)
23 BOOST_PARAMETER_NAME(y)
24 BOOST_PARAMETER_NAME(z)
25 } // namespace test
26
27 #if !defined(BOOST_PARAMETER_CAN_USE_MP11)
28 #include <boost/mpl/bool.hpp>
29 #include <boost/mpl/if.hpp>
30 #include <boost/type_traits/is_convertible.hpp>
31
32 namespace test {
33
34 struct f_predicate
35 {
36 template <typename T, typename Args>
37 struct apply
38 : boost::mpl::if_<
39 boost::is_convertible<T,int>
40 , boost::mpl::true_
41 , boost::mpl::false_
42 >
43 {
44 };
45 };
46 } // namespace test
47
48 #endif // BOOST_PARAMETER_CAN_USE_MP11
49
50 #include <boost/parameter/parameters.hpp>
51
52 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
53 #include <boost/mp11/bind.hpp>
54 #include <type_traits>
55 #endif
56
57 namespace test {
58
59 struct f_parameters // vc6 is happier with inheritance than with a typedef
60 : boost::parameter::parameters<
61 boost::parameter::required<test::tag::w>
62 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
63 , boost::parameter::optional<
64 test::tag::x
65 , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
66 >
67 , boost::parameter::optional<
68 test::tag::y
69 , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
70 >
71 , boost::parameter::optional<
72 test::tag::z
73 , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
74 >
75 #else
76 , boost::parameter::optional<test::tag::x,test::f_predicate>
77 , boost::parameter::optional<test::tag::y,test::f_predicate>
78 , boost::parameter::optional<test::tag::z,test::f_predicate>
79 #endif // BOOST_PARAMETER_CAN_USE_MP11
80 >
81 {
82 };
83 } // namespace test
84
85 #include <boost/parameter/macros.hpp>
86 #include <boost/core/lightweight_test.hpp>
87
88 namespace test {
89
90 #if defined(BOOST_NO_VOID_RETURNS)
91 BOOST_PARAMETER_FUN(int, f, 1, 4, f_parameters)
92 #else
93 BOOST_PARAMETER_FUN(void, f, 1, 4, f_parameters)
94 #endif
95 {
96 BOOST_TEST_EQ(p[test::_w][0], p[test::_x | -1]);
97 BOOST_TEST_EQ(p[test::_w][1], p[test::_y | -2]);
98 BOOST_TEST_EQ(p[test::_w][2], p[test::_z | -3]);
99 #if defined(BOOST_NO_VOID_RETURNS)
100 return 0;
101 #endif
102 }
103 } // namespace test
104
105 int main()
106 {
107 int a[3];
108 a[0] = 1;
109 a[1] = 2;
110 a[2] = 3;
111 test::f(test::_x = 1, test::_y = 2, test::_z = 3, test::_w = a);
112 a[1] = -2;
113 a[2] = -3;
114 test::f(test::_x = 1, test::_w = a);
115 a[0] = -1;
116 a[1] = 2;
117 test::f(test::_y = 2, test::_w = a);
118 a[1] = -2;
119 a[2] = 3;
120 test::f(test::_z = 3, test::_w = a);
121 a[0] = 1;
122 test::f(test::_z = 3, test::_x = 1, test::_w = a);
123 return boost::report_errors();
124 }
125