2 // (C) Copyright John Maddock 2000.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/config.hpp>
11 #include <boost/detail/workaround.hpp>
13 #if defined(_WIN32_WCE) && defined(BOOST_MSVC)
14 #pragma warning(disable:4201)
17 #include <boost/noncopyable.hpp>
22 // we have to turn off these warnings otherwise we get swamped by the things:
23 #pragma option -w-8008 -w-8066
27 // We have to turn off warnings that occur within the test suite:
28 #pragma warning(disable:4127)
31 // remark #1418: external function definition with no prior declaration
32 // remark #981: operands are evaluated in unspecified order
33 #pragma warning(disable:1418 981)
37 // turn off warnings from this header:
39 #pragma warning(disable:444)
43 // basic configuration:
49 //#define TYPE_TRAITS(x) <type_traits>
50 //#define TYPE_COMPARE(x) <type_compare>
51 //#define TYPE_TRANSFORM(x) <type_transform>
57 //#define TYPE_TRAITS(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
58 //#define TYPE_COMPARE(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
59 //#define TYPE_TRANSFORM(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
64 // replacements for Unit test macros:
68 #define BOOST_CHECK_MESSAGE(pred, message)\
72 std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\
77 #define BOOST_WARN_MESSAGE(pred, message)\
81 std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\
85 #define BOOST_TEST_MESSAGE(message)\
86 do{ std::cout << __FILE__ << ":" << __LINE__ << ": " << message << std::endl; }while(0)
88 #define BOOST_CHECK(pred)\
91 std::cout << __FILE__ << ":" << __LINE__ << ": Error in " << BOOST_STRINGIZE(pred) << std::endl;\
96 #define TT_TEST_BEGIN(trait_name)\
98 #define TT_TEST_END return error_count; }
100 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !BOOST_WORKAROUND(BOOST_GCC, < 40704)
102 #define TRANSFORM_CHECK_ALIASES(name, from_suffix, to_suffix)\
103 BOOST_CHECK_TYPE(bool to_suffix, name##_t<bool from_suffix>);\
104 BOOST_CHECK_TYPE(char to_suffix, name##_t<char from_suffix>);\
105 BOOST_CHECK_TYPE(wchar_t to_suffix, name##_t<wchar_t from_suffix>);\
106 BOOST_CHECK_TYPE(signed char to_suffix, name##_t<signed char from_suffix>);\
107 BOOST_CHECK_TYPE(unsigned char to_suffix, name##_t<unsigned char from_suffix>);\
108 BOOST_CHECK_TYPE(short to_suffix, name##_t<short from_suffix>);\
109 BOOST_CHECK_TYPE(unsigned short to_suffix, name##_t<unsigned short from_suffix>);\
110 BOOST_CHECK_TYPE(int to_suffix, name##_t<int from_suffix>);\
111 BOOST_CHECK_TYPE(unsigned int to_suffix, name##_t<unsigned int from_suffix>);\
112 BOOST_CHECK_TYPE(long to_suffix, name##_t<long from_suffix>);\
113 BOOST_CHECK_TYPE(unsigned long to_suffix, name##_t<unsigned long from_suffix>);\
114 BOOST_CHECK_TYPE(float to_suffix, name##_t<float from_suffix>);\
115 BOOST_CHECK_TYPE(long double to_suffix, name##_t<long double from_suffix>);\
116 BOOST_CHECK_TYPE(double to_suffix, name##_t<double from_suffix>);\
117 BOOST_CHECK_TYPE(UDT to_suffix, name##_t<UDT from_suffix>);\
118 BOOST_CHECK_TYPE(enum1 to_suffix, name##_t<enum1 from_suffix>);
122 #define TRANSFORM_CHECK_ALIASES(name, from_suffix, to_suffix) /**/
126 #define TRANSFORM_CHECK(name, from_suffix, to_suffix)\
127 TRANSFORM_CHECK_ALIASES(name, from_suffix, to_suffix)\
128 BOOST_CHECK_TYPE(bool to_suffix, name<bool from_suffix>::type);\
129 BOOST_CHECK_TYPE(char to_suffix, name<char from_suffix>::type);\
130 BOOST_CHECK_TYPE(wchar_t to_suffix, name<wchar_t from_suffix>::type);\
131 BOOST_CHECK_TYPE(signed char to_suffix, name<signed char from_suffix>::type);\
132 BOOST_CHECK_TYPE(unsigned char to_suffix, name<unsigned char from_suffix>::type);\
133 BOOST_CHECK_TYPE(short to_suffix, name<short from_suffix>::type);\
134 BOOST_CHECK_TYPE(unsigned short to_suffix, name<unsigned short from_suffix>::type);\
135 BOOST_CHECK_TYPE(int to_suffix, name<int from_suffix>::type);\
136 BOOST_CHECK_TYPE(unsigned int to_suffix, name<unsigned int from_suffix>::type);\
137 BOOST_CHECK_TYPE(long to_suffix, name<long from_suffix>::type);\
138 BOOST_CHECK_TYPE(unsigned long to_suffix, name<unsigned long from_suffix>::type);\
139 BOOST_CHECK_TYPE(float to_suffix, name<float from_suffix>::type);\
140 BOOST_CHECK_TYPE(long double to_suffix, name<long double from_suffix>::type);\
141 BOOST_CHECK_TYPE(double to_suffix, name<double from_suffix>::type);\
142 BOOST_CHECK_TYPE(UDT to_suffix, name<UDT from_suffix>::type);\
143 BOOST_CHECK_TYPE(enum1 to_suffix, name<enum1 from_suffix>::type);
145 #define BOOST_DUMMY_MACRO_PARAM /**/
147 #define BOOST_DECL_TRANSFORM_TEST(name, type, from, to)\
148 void name(){ TRANSFORM_CHECK(type, from, to) }
149 #define BOOST_DECL_TRANSFORM_TEST3(name, type, from)\
150 void name(){ TRANSFORM_CHECK(type, from, BOOST_DUMMY_MACRO_PARAM) }
151 #define BOOST_DECL_TRANSFORM_TEST2(name, type, to)\
152 void name(){ TRANSFORM_CHECK(type, BOOST_DUMMY_MACRO_PARAM, to) }
153 #define BOOST_DECL_TRANSFORM_TEST0(name, type)\
154 void name(){ TRANSFORM_CHECK(type, BOOST_DUMMY_MACRO_PARAM, BOOST_DUMMY_MACRO_PARAM) }
159 // VC++ emits an awful lot of warnings unless we define these:
161 # pragma warning(disable:4800)
165 // define some test types:
167 enum enum_UDT{ one, two, three };
173 UDT& operator=(const UDT&);
180 #if __cpp_noexcept_function_type
182 int f6(int)noexcept(true);
183 double f7()noexcept(false);
188 typedef int(*f2)(int);
189 typedef int(*f3)(int, bool);
190 typedef void (UDT::*mf1)();
191 typedef int (UDT::*mf2)();
192 typedef int (UDT::*mf3)(int);
193 typedef int (UDT::*mf4)(int, float);
194 typedef int (UDT::*mp);
195 typedef int (UDT::*cmf)(int) const;
196 #if __cpp_noexcept_function_type
197 typedef void (UDT::*mf5)()noexcept;
198 typedef int (UDT::*mf6)(int)noexcept;
199 typedef double (UDT::*mf7)()noexcept;
201 typedef int (UDT::*mf8)(...);
203 // cv-qualifiers applied to reference types should have no effect
204 // declare these here for later use with is_reference and remove_reference:
206 # pragma warning(push)
207 # pragma warning(disable: 4181)
208 # elif defined(BOOST_INTEL)
209 # pragma warning(push)
210 # pragma warning(disable: 21)
211 # elif defined(BOOST_CLANG)
212 # pragma clang diagnostic push
213 # pragma clang diagnostic ignored "-Wignored-qualifiers"
216 // This is intentional:
217 // r_type and cr_type should be the same type
218 // but some compilers wrongly apply cv-qualifiers
219 // to reference types (this may generate a warning
220 // on some compilers):
224 typedef const r_type cr_type;
226 // recent Intel compilers generate a hard error on the above:
227 typedef r_type cr_type;
230 # pragma warning(pop)
231 # elif defined(BOOST_INTEL)
232 # pragma warning(pop)
233 # pragma warning(disable: 985) // identifier truncated in debug information
234 # elif defined(BOOST_CLANG)
235 # pragma clang diagnostic pop
238 struct POD_UDT { int x; };
242 empty_UDT(const empty_UDT&);
244 empty_UDT& operator=(const empty_UDT&);
245 bool operator==(const empty_UDT&)const;
249 bool operator==(const empty_POD_UDT&)const
263 union empty_union_UDT
267 union empty_POD_union_UDT{};
269 struct nothrow_copy_UDT
272 nothrow_copy_UDT(const nothrow_copy_UDT&)throw();
273 ~nothrow_copy_UDT(){}
274 nothrow_copy_UDT& operator=(const nothrow_copy_UDT&);
275 bool operator==(const nothrow_copy_UDT&)const
279 struct nothrow_assign_UDT
281 nothrow_assign_UDT();
282 nothrow_assign_UDT(const nothrow_assign_UDT&);
283 ~nothrow_assign_UDT(){};
284 nothrow_assign_UDT& operator=(const nothrow_assign_UDT&)throw(){ return *this; }
285 bool operator==(const nothrow_assign_UDT&)const
289 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
290 struct nothrow_move_UDT
293 nothrow_move_UDT(nothrow_move_UDT&&) throw();
294 nothrow_move_UDT& operator=(nothrow_move_UDT&&) throw();
295 bool operator==(const nothrow_move_UDT&)const
301 struct nothrow_construct_UDT
303 nothrow_construct_UDT()throw();
304 nothrow_construct_UDT(const nothrow_construct_UDT&);
305 ~nothrow_construct_UDT(){};
306 nothrow_construct_UDT& operator=(const nothrow_construct_UDT&){ return *this; }
307 bool operator==(const nothrow_construct_UDT&)const
313 class Derived : public Base { };
314 class Derived2 : public Base { };
315 class MultiBase : public Derived, public Derived2 {};
316 class PrivateBase : private Base {};
318 class NonDerived { };
330 #ifndef BOOST_NO_CXX11_SCOPED_ENUMS
332 enum class scoped_enum { one, two, three };
341 struct VD : public VB
346 // struct non_pointer:
347 // used to verify that is_pointer does not return
348 // true for class types that implement operator void*()
352 operator void*(){return this;}
354 struct non_int_pointer
357 operator int*(){return &i;}
359 struct int_constructible
361 int_constructible(int);
363 struct int_convertible
369 // used to verify that is_empty does not emit
370 // spurious warnings or errors.
372 struct non_empty : private boost::noncopyable
377 // abstract base classes:
381 virtual ~test_abc1();
382 test_abc1(const test_abc1&);
383 test_abc1& operator=(const test_abc1&);
384 virtual void foo() = 0;
385 virtual void foo2() = 0;
390 virtual ~test_abc2();
391 virtual void foo() = 0;
392 virtual void foo2() = 0;
395 struct test_abc3 : public test_abc1
397 virtual void foo3() = 0;
400 struct incomplete_type;
402 struct polymorphic_base
404 virtual ~polymorphic_base();
405 virtual void method();
408 struct polymorphic_derived1 : public polymorphic_base
412 struct polymorphic_derived2 : public polymorphic_base
414 virtual void method();
417 #ifndef BOOST_NO_CXX11_FINAL
418 struct final_UDT final
420 struct polymorphic_derived_final final : public polymorphic_derived2
425 struct virtual_inherit1 : public virtual Base { };
426 struct virtual_inherit2 : public virtual_inherit1 { };
427 struct virtual_inherit3 : private virtual Base {};
428 struct virtual_inherit4 : public virtual boost::noncopyable {};
429 struct virtual_inherit5 : public virtual int_convertible {};
430 struct virtual_inherit6 : public virtual Base { virtual ~virtual_inherit6()throw(); };
432 typedef void foo0_t();
433 typedef void foo1_t(int);
434 typedef void foo2_t(int&, double);
435 typedef void foo3_t(int&, bool, int, int);
436 typedef void foo4_t(int, bool, int*, int[], int, int, int, int, int);
438 struct trivial_except_construct
440 trivial_except_construct();
444 struct trivial_except_destroy
446 ~trivial_except_destroy();
450 struct trivial_except_copy
452 trivial_except_copy(trivial_except_copy const&);
456 struct trivial_except_assign
458 trivial_except_assign& operator=(trivial_except_assign const&);
470 wrap& operator=(const wrap&);