]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/has_prefix_operators.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_traits / test / has_prefix_operators.hpp
1 // (C) Copyright Frederic Bron 2009-2011.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef TT_HAS_PREFIX_OPERATORS_HPP
7 #define TT_HAS_PREFIX_OPERATORS_HPP
8
9 #if defined(__GNUC__) && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ > 40900)
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wunused-function"
12 #endif
13
14 // test with one template parameter
15 #define TEST_T(TYPE,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE>::value), RESULT)
16 // test with one template parameter plus return value
17 #define TEST_TR(TYPE,RET,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE,RET>::value), RESULT)
18
19 namespace {
20
21 struct without { };
22
23 struct ret { };
24
25 struct internal { ret operator BOOST_TT_TRAIT_OP () const; };
26
27 struct external { };
28 inline ret operator BOOST_TT_TRAIT_OP (const external&){ return ret(); }
29
30 struct comma1_ret { };
31 struct ret_with_comma1 { comma1_ret operator,(int); };
32
33 struct internal_comma1 { ret_with_comma1 operator BOOST_TT_TRAIT_OP () const; };
34
35 struct external_comma1 { };
36 inline ret_with_comma1 operator BOOST_TT_TRAIT_OP (const external_comma1&){ return ret_with_comma1(); }
37
38 struct ret_with_comma2 { void operator,(int); };
39
40 struct internal_comma2 { ret_with_comma2 operator BOOST_TT_TRAIT_OP () const; };
41
42 struct external_comma2 { };
43 inline ret_with_comma2 operator BOOST_TT_TRAIT_OP (const external_comma2&){ return ret_with_comma2(); }
44
45 struct returns_int { int operator BOOST_TT_TRAIT_OP (); };
46
47 struct returns_void { void operator BOOST_TT_TRAIT_OP (); };
48
49 struct returns_void_star { void *operator BOOST_TT_TRAIT_OP (); };
50
51 struct returns_double { double operator BOOST_TT_TRAIT_OP (); };
52
53 struct ret1 { };
54 struct convertible_to_ret1 { operator ret1 () const; };
55 struct returns_convertible_to_ret1 { convertible_to_ret1 operator BOOST_TT_TRAIT_OP (); };
56
57 struct convertible_to_ret2 { };
58 struct ret2 { ret2(const convertible_to_ret2); };
59 struct returns_convertible_to_ret2 { convertible_to_ret2 operator BOOST_TT_TRAIT_OP (); };
60
61 class Base1 { };
62 class Derived1 : public Base1 { };
63
64 inline bool operator BOOST_TT_TRAIT_OP (const Base1&) { return true; }
65
66 class Base2 { };
67 struct Derived2 : public Base2 {
68 Derived2(int); // to check if it works with a class that is not default constructible
69 };
70
71 bool operator BOOST_TT_TRAIT_OP (const Derived2&) { return true; }
72
73 struct tag { };
74
75 //class internal_private { ret operator BOOST_TT_TRAIT_OP () const; };
76
77 void common() {
78 TEST_T(void, false);
79 TEST_TR(void, void, false);
80 TEST_TR(void, int, false);
81
82 TEST_T(without, false);
83 TEST_T(internal, true);
84 TEST_T(external, true);
85 TEST_T(internal_comma1, true);
86 TEST_T(external_comma1, true);
87 TEST_T(internal_comma2, true);
88 TEST_T(external_comma2, true);
89 TEST_T(returns_int, true);
90 TEST_T(returns_void, true);
91 TEST_T(returns_void_star, true);
92 TEST_T(returns_double, true);
93 TEST_T(returns_convertible_to_ret1, true);
94 TEST_T(returns_convertible_to_ret2, true);
95 TEST_T(Base1, true);
96 TEST_T(Derived1, true);
97 TEST_T(Base2, false);
98 TEST_T(Derived2, true);
99
100 TEST_TR(without, void, false);
101 TEST_TR(without, bool, false);
102 TEST_TR(internal_comma1, void, false);
103 TEST_TR(internal_comma1, bool, false);
104 TEST_TR(internal_comma1, ret_with_comma1, true);
105 TEST_TR(internal_comma2, void, false);
106 TEST_TR(internal_comma2, bool, false);
107 TEST_TR(internal_comma2, ret_with_comma2, true);
108 TEST_TR(external, void, false);
109 TEST_TR(external, bool, false);
110 TEST_TR(external, ret, true);
111 TEST_TR(returns_int, void, false);
112 TEST_TR(returns_int, bool, true);
113 TEST_TR(returns_int, int, true);
114 TEST_TR(returns_void, void, true);
115 TEST_TR(returns_void, bool, false);
116 TEST_TR(returns_void_star, bool, true);
117 TEST_TR(returns_double, void, false);
118 TEST_TR(returns_double, bool, true);
119 TEST_TR(returns_double, double, true);
120 TEST_TR(returns_convertible_to_ret1, void, false);
121 TEST_TR(returns_convertible_to_ret1, ret1, true);
122 TEST_TR(returns_convertible_to_ret2, ret2, true);
123 TEST_TR(Base1, bool, true);
124 TEST_TR(Derived1, bool, true);
125 TEST_TR(Base2, bool, false);
126 TEST_TR(Derived2, bool, true);
127 // compile time error
128 // TEST_T(internal_private, false);
129 }
130
131 }
132
133 #if defined(__GNUC__) && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ > 40900)
134 #pragma GCC diagnostic pop
135 #endif
136
137 #endif
138