]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/basics.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / parameter / test / basics.hpp
1 // Copyright David Abrahams, Daniel Wallin 2005.
2 // Copyright Cromwell D. Enage 2017.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #ifndef BOOST_PARAMETER_TEST_BASICS_HPP
8 #define BOOST_PARAMETER_TEST_BASICS_HPP
9
10 #include <boost/parameter.hpp>
11
12 #if (BOOST_PARAMETER_MAX_ARITY < 4)
13 #error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater.
14 #endif
15 #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
16 (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5)
17 #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
18 as 5 or greater.
19 #endif
20
21 #if !defined(BOOST_PARAMETER_CAN_USE_MP11)
22 #include <boost/mpl/bool.hpp>
23 #include <boost/mpl/if.hpp>
24 #include <boost/mpl/assert.hpp>
25 #include <boost/type_traits/is_same.hpp>
26 #endif
27
28 #include <boost/core/lightweight_test.hpp>
29
30 namespace test {
31
32 BOOST_PARAMETER_NAME(name)
33 BOOST_PARAMETER_NAME(value)
34 BOOST_PARAMETER_NAME(index)
35 BOOST_PARAMETER_NAME(tester)
36
37 struct f_parameters // vc6 is happier with inheritance than with a typedef
38 : boost::parameter::parameters<
39 test::tag::tester
40 , test::tag::name
41 , test::tag::value
42 , test::tag::index
43 >
44 {
45 };
46
47 inline double value_default()
48 {
49 return 666.222;
50 }
51
52 template <typename T>
53 inline bool equal(T const& x, T const& y)
54 {
55 return x == y;
56 }
57
58 template <typename Name, typename Value, typename Index>
59 struct values_t
60 {
61 values_t(Name const& n_, Value const& v_, Index const& i_)
62 : n(n_), v(v_), i(i_)
63 {
64 }
65
66 template <typename Name_, typename Value_, typename Index_>
67 void
68 operator()(
69 Name_ const& n_
70 , Value_ const& v_
71 , Index_ const& i_
72 ) const
73 {
74 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
75 static_assert(
76 std::is_same<Index,Index_>::value
77 , "Index == Index_"
78 );
79 static_assert(
80 std::is_same<Value,Value_>::value
81 , "Value == Value_"
82 );
83 static_assert(
84 std::is_same<Name,Name_>::value
85 , "Name == Name_"
86 );
87 #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
88 BOOST_MPL_ASSERT((
89 typename boost::mpl::if_<
90 boost::is_same<Index,Index_>
91 , boost::mpl::true_
92 , boost::mpl::false_
93 >::type
94 ));
95 BOOST_MPL_ASSERT((
96 typename boost::mpl::if_<
97 boost::is_same<Value,Value_>
98 , boost::mpl::true_
99 , boost::mpl::false_
100 >::type
101 ));
102 BOOST_MPL_ASSERT((
103 typename boost::mpl::if_<
104 boost::is_same<Name,Name_>
105 , boost::mpl::true_
106 , boost::mpl::false_
107 >::type
108 ));
109 #endif // BOOST_PARAMETER_CAN_USE_MP11
110 BOOST_TEST(test::equal(n, n_));
111 BOOST_TEST(test::equal(v, v_));
112 BOOST_TEST(test::equal(i, i_));
113 }
114
115 Name const& n;
116 Value const& v;
117 Index const& i;
118 };
119
120 template <typename Name, typename Value, typename Index>
121 inline test::values_t<Name,Value,Index>
122 values(Name const& n, Value const& v, Index const& i)
123 {
124 return test::values_t<Name,Value,Index>(n, v, i);
125 }
126 } // namespace test
127
128 #endif // include guard
129