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)
8 # include <type_traits>
10 #include <boost/type_traits/alignment_of.hpp>
11 #include <boost/type_traits/has_nothrow_assign.hpp>
12 #include <boost/type_traits/has_nothrow_constructor.hpp>
13 #include <boost/type_traits/has_nothrow_copy.hpp>
14 #include <boost/type_traits/is_base_and_derived.hpp>
15 #include <boost/type_traits/is_base_of.hpp>
16 #include <boost/type_traits/is_same.hpp>
17 #include <boost/type_traits/is_convertible.hpp>
18 #include <boost/type_traits/is_polymorphic.hpp>
19 #include <boost/type_traits/is_member_pointer.hpp>
20 #include <boost/type_traits/is_member_object_pointer.hpp>
21 #include <boost/type_traits/is_member_function_pointer.hpp>
22 #include <boost/type_traits/is_pointer.hpp>
25 #include "check_integral_constant.hpp"
31 // VC++ emits an awful lot of warnings unless we define these:
33 # pragma warning(disable:4244)
42 static std::ptrdiff_t get()
44 static align_calc
<T
> a
;
45 return reinterpret_cast<const char*>(&(a
.instance
)) - reinterpret_cast<const char*>(&(a
.padding
));
49 #define ALIGNOF(x) align_calc<x>::get()
52 TT_TEST_BEGIN(tricky_partial_specialization_test
)
54 // corner cases which don't compile without partial specialization
58 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of
<char&>::value
, ALIGNOF(void*));
59 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of
<char (&)(int)>::value
, ALIGNOF(void*));
60 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::alignment_of
<char(&)[4]>::value
, ALIGNOF(void*));
62 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
&,Derived
>::value
), false);
63 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
&,Derived
&>::value
), false);
64 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
,Derived
&>::value
), false);
65 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
,void>::value
), false);
66 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
67 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
&&,Derived
>::value
), false);
68 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
&&,Derived
&&>::value
), false);
69 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_of
<Base
,Derived
&&>::value
), false);
72 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<void, int>::value
), false);
73 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<void, void>::value
), true);
74 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<void, const void>::value
), false);
75 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<test_abc1
, test_abc1
>::value
), true);
76 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same
<test_abc1
, const test_abc1
>::value
), false);
78 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible
<void,float>::value
), false);
80 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const UDT
>::value
, false);
81 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<volatile empty_UDT
>::value
, false);
82 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const VB
>::value
, true);
83 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const volatile VD
>::value
, true);
84 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const test_abc1
>::value
, true);
85 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<volatile test_abc2
>::value
, true);
86 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const std::exception
>::value
, true);
87 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const std::bad_alloc
>::value
, true);
88 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const std::runtime_error
>::value
, true);
89 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const std::out_of_range
>::value
, true);
90 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic
<const std::range_error
>::value
, true);
92 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer
<const f1
>::value
, true);
93 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer
<volatile f1
>::value
, true);
94 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_pointer
<const volatile f1
>::value
, true);
96 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<const f1
>::value
, false);
97 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<const mp
>::value
, true);
98 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<volatile mp
>::value
, true);
99 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<const volatile mp
>::value
, true);
100 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<const mf3
>::value
, true);
101 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<volatile mf3
>::value
, true);
102 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_pointer
<const volatile mf3
>::value
, true);
104 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<const f1
>::value
, false);
105 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<const mp
>::value
, true);
106 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<volatile mp
>::value
, true);
107 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<const volatile mp
>::value
, true);
108 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<const mf3
>::value
, false);
109 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<volatile mf3
>::value
, false);
110 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_object_pointer
<const volatile mf3
>::value
, false);
112 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<const f1
>::value
, false);
113 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<const mp
>::value
, false);
114 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<volatile mp
>::value
, false);
115 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<const volatile mp
>::value
, false);
116 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<const mf3
>::value
, true);
117 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<volatile mf3
>::value
, true);
118 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer
<const volatile mf3
>::value
, true);