]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/type_traits/test/has_postfix_operators.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / type_traits / test / has_postfix_operators.hpp
CommitLineData
7c673cae
FG
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_POSTFIX_OPERATORS_HPP
7#define TT_HAS_POSTFIX_OPERATORS_HPP
8
92f5a8d4
TL
9// It would be nice to get rid of the unnamed namespace here,
10// but for now we just turn off inspection reporting :(
11// boostinspect:nounnamed
12
7c673cae
FG
13// test with one template parameter
14#define TEST_T(TYPE,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE>::value), RESULT)
15// test with one template parameter plus return value
16#define TEST_TR(TYPE,RET,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE,RET>::value), RESULT)
17
18namespace {
19
20struct without { };
21
22struct ret { };
23
24struct internal { ret operator BOOST_TT_TRAIT_OP (int) const; };
25
26struct external { };
27inline ret operator BOOST_TT_TRAIT_OP (const external&, int){ return ret(); }
28
29struct comma1_ret { };
30struct ret_with_comma1 { comma1_ret operator,(int); };
31
32struct internal_comma1 { ret_with_comma1 operator BOOST_TT_TRAIT_OP (int) const; };
33
34struct external_comma1 { };
35inline ret_with_comma1 operator BOOST_TT_TRAIT_OP (const external_comma1&, int){ return ret_with_comma1(); }
36
37struct ret_with_comma2 { void operator,(int); };
38
39struct internal_comma2 { ret_with_comma2 operator BOOST_TT_TRAIT_OP (int) const; };
40
41struct external_comma2 { };
42inline ret_with_comma2 operator BOOST_TT_TRAIT_OP (const external_comma2&, int){ return ret_with_comma2(); }
43
44struct returns_int { int operator BOOST_TT_TRAIT_OP (int); };
45
46struct returns_void { void operator BOOST_TT_TRAIT_OP (int); };
47
48struct returns_void_star { void *operator BOOST_TT_TRAIT_OP (int); };
49
50struct returns_double { double operator BOOST_TT_TRAIT_OP (int); };
51
52struct ret1 { };
53struct convertible_to_ret1 { operator ret1 () const; };
54struct returns_convertible_to_ret1 { convertible_to_ret1 operator BOOST_TT_TRAIT_OP (int); };
55
56struct convertible_to_ret2 { };
57struct ret2 { ret2(const convertible_to_ret2); };
58struct returns_convertible_to_ret2 { convertible_to_ret2 operator BOOST_TT_TRAIT_OP (int); };
59
60class Base1 { };
61class Derived1 : public Base1 { };
62
63inline bool operator BOOST_TT_TRAIT_OP (const Base1&, int) { return true; }
64
65class Base2 { };
66struct Derived2 : public Base2 {
67 Derived2(int); // to check if it works with a class that is not default constructible
68};
69
70inline bool operator BOOST_TT_TRAIT_OP (const Derived2&, int) { return true; }
71
72struct tag { };
73
74//class internal_private { ret operator BOOST_TT_TRAIT_OP (int) const; };
75
76void common() {
77 TEST_T(void, false);
78 TEST_TR(void, void, false);
79 TEST_TR(void, int, false);
80
81 TEST_T(without, false);
82 TEST_T(internal, true);
83 TEST_T(external, true);
84 TEST_T(internal_comma1, true);
85 TEST_T(external_comma1, true);
86 TEST_T(internal_comma2, true);
87 TEST_T(external_comma2, true);
88 TEST_T(returns_int, true);
89 TEST_T(returns_void, true);
90 TEST_T(returns_void_star, true);
91 TEST_T(returns_double, true);
92 TEST_T(returns_convertible_to_ret1, true);
93 TEST_T(returns_convertible_to_ret2, true);
94 TEST_T(Base1, true);
95 TEST_T(Derived1, true);
96 TEST_T(Base2, false);
97 TEST_T(Derived2, true);
98
99 TEST_TR(without, void, false);
100 TEST_TR(without, bool, false);
101 TEST_TR(internal, void, false);
102 TEST_TR(internal, bool, false);
103 TEST_TR(internal, ret, true);
104 TEST_TR(internal_comma1, void, false);
105 TEST_TR(internal_comma1, bool, false);
106 TEST_TR(internal_comma1, ret_with_comma1, true);
107 TEST_TR(internal_comma2, void, false);
108 TEST_TR(internal_comma2, bool, false);
109 TEST_TR(internal_comma2, ret_with_comma2, true);
110 TEST_TR(external, void, false);
111 TEST_TR(external, bool, false);
112 TEST_TR(external, ret, true);
113 TEST_TR(returns_int, void, false);
114 TEST_TR(returns_int, bool, true);
115 TEST_TR(returns_int, int, true);
116 TEST_TR(returns_void, void, true);
117 TEST_TR(returns_void, bool, false);
118 TEST_TR(returns_void_star, bool, true);
119 TEST_TR(returns_double, void, false);
120 TEST_TR(returns_double, bool, true);
121 TEST_TR(returns_double, double, true);
122 TEST_TR(returns_convertible_to_ret1, void, false);
123 TEST_TR(returns_convertible_to_ret1, ret1, true);
124 TEST_TR(returns_convertible_to_ret2, ret2, true);
125 TEST_TR(Base1, bool, true);
126 TEST_TR(Derived1, bool, true);
127 TEST_TR(Base2, bool, false);
128 TEST_TR(Derived2, bool, true);
129// compile time error
130// TEST_T(internal_private, false);
131}
132
133}
134
135#endif
136