]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/basics.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / parameter / test / basics.hpp
1 // Copyright David Abrahams, Daniel Wallin 2005. Use, modification and
2 // distribution is subject to 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 #ifndef BASICS_050424_HPP
7 #define BASICS_050424_HPP
8
9 #include <boost/parameter/keyword.hpp>
10 #include <boost/parameter/parameters.hpp>
11 #include <boost/type_traits/is_same.hpp>
12 #include <boost/assert.hpp>
13 #include <boost/mpl/assert.hpp>
14 #include <cstring>
15 #include <boost/detail/lightweight_test.hpp>
16
17 namespace test {
18
19 BOOST_PARAMETER_KEYWORD(tag, name)
20 BOOST_PARAMETER_KEYWORD(tag, value)
21 BOOST_PARAMETER_KEYWORD(tag, index)
22 BOOST_PARAMETER_KEYWORD(tag, tester)
23
24 using namespace boost::parameter;
25
26 struct f_parameters // vc6 is happier with inheritance than with a typedef
27 : parameters<
28 tag::tester
29 , tag::name
30 , tag::value
31 , tag::index
32 >
33 {};
34
35 inline double value_default()
36 {
37 return 666.222;
38 }
39
40 template <class T>
41 inline bool equal(T const& x, T const& y)
42 {
43 return x == y;
44 }
45
46 inline bool equal(char const* s1, char const* s2)
47 {
48 using namespace std;
49 return !strcmp(s1,s2);
50 }
51
52 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
53 inline bool equal(char* s1, char* s2)
54 {
55 using namespace std;
56 return !strcmp(s1,s2);
57 }
58 #endif
59
60 template <class Name, class Value, class Index>
61 struct values_t
62 {
63 values_t(Name const& n, Value const& v, Index const& i)
64 : n(n), v(v), i(i)
65 {}
66
67 template <class Name_, class Value_, class Index_>
68 void operator()(Name_ const& n_, Value_ const& v_, Index_ const& i_) const
69 {
70
71 // Only VC and its emulators fail this; they seem to have
72 // problems with deducing the constness of string literal
73 // arrays.
74 #if defined(_MSC_VER) \
75 && (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) \
76 || BOOST_WORKAROUND(BOOST_MSVC, < 1310)) \
77 || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
78 # else
79 BOOST_MPL_ASSERT((boost::is_same<Index,Index_>));
80 BOOST_MPL_ASSERT((boost::is_same<Value,Value_>));
81 BOOST_MPL_ASSERT((boost::is_same<Name,Name_>));
82 #endif
83 BOOST_TEST(equal(n, n_));
84 BOOST_TEST(equal(v, v_));
85 BOOST_TEST(equal(i, i_));
86 }
87
88 Name const& n;
89 Value const& v;
90 Index const& i;
91 };
92
93 template <class Name, class Value, class Index>
94 inline values_t<Name,Value,Index>
95 values(Name const& n, Value const& v, Index const& i)
96 {
97 return values_t<Name,Value,Index>(n,v,i);
98 }
99
100 } // namespace test
101
102 // GCC2 has a problem with char (&)[] deduction, so we'll cast string
103 // literals there.
104 #undef S
105 #if BOOST_WORKAROUND(__GNUC__, == 2) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
106 # define S(s) (char const*)s
107 #else
108 # define S(s) s
109 #endif
110
111 #endif // BASICS_050424_HPP
112