]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/aligned_storage_a2_test.cpp
6 // (C) Copyright John Maddock 2000.
7 // Use, modification and distribution are subject to the
8 // Boost Software License, Version 1.0. (See accompanying file
9 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 # include <type_traits>
13 # include <boost/type_traits/type_with_alignment.hpp> // max_align and long_long_type
15 # include <boost/type_traits/alignment_of.hpp>
16 # include <boost/type_traits/aligned_storage.hpp>
17 # include <boost/type_traits/is_pod.hpp>
20 #include "check_integral_constant.hpp"
30 inline void no_unused_warning(const volatile T
&)
35 void do_check(const T
&)
37 typedef typename
tt::aligned_storage
<T::value
,T::value
>::type t1
;
38 #if defined(BOOST_GCC) && (BOOST_GCC < 40800)
39 // In order to test this with warnings-as-errors with GCC, we need
40 // a slightly different initializer here to suppress spurious
41 // GCC warnings (ie to work around a GCC buglet).
47 no_unused_warning(as1
);
48 no_unused_warning(pod1
);
49 BOOST_TEST_MESSAGE(typeid(t1
).name());
50 BOOST_CHECK(::tt::alignment_of
<t1
>::value
== T::value
);
51 BOOST_CHECK(sizeof(t1
) == T::value
);
52 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
53 BOOST_CHECK(::tt::is_pod
<t1
>::value
== true);
55 typedef typename
tt::aligned_storage
<T::value
*2,T::value
>::type t2
;
56 #if defined(BOOST_GCC) && (BOOST_GCC < 40800)
62 no_unused_warning(as2
);
63 no_unused_warning(pod2
);
64 BOOST_TEST_MESSAGE(typeid(t2
).name());
65 BOOST_CHECK(::tt::alignment_of
<t2
>::value
== T::value
);
66 BOOST_CHECK(sizeof(t2
) == T::value
*2);
67 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
68 BOOST_CHECK(::tt::is_pod
<t2
>::value
== true);
73 typedef typename
tt::aligned_storage
<T::value
,(std::size_t)(-1L)>::type t3
;
74 #if defined(BOOST_GCC) && (BOOST_GCC < 40800)
80 no_unused_warning(as3
);
81 no_unused_warning(pod3
);
82 BOOST_TEST_MESSAGE(typeid(t3
).name());
83 BOOST_CHECK(::tt::alignment_of
<t3
>::value
== ::tt::alignment_of
< ::boost::detail::max_align
>::value
);
84 BOOST_CHECK((sizeof(t3
) % T::value
) == 0);
85 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
86 BOOST_CHECK(::tt::is_pod
<t3
>::value
== true);
91 TT_TEST_BEGIN(type_with_alignment
)
93 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<char>::value
>());
94 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<short>::value
>());
95 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<int>::value
>());
96 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<long>::value
>());
97 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<float>::value
>());
98 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<double>::value
>());
99 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<long double>::value
>());
101 #ifdef BOOST_HAS_LONG_LONG
102 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
< ::boost::long_long_type
>::value
>());
104 #ifdef BOOST_HAS_MS_INT64
105 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<__int64
>::value
>());
107 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<int[4]>::value
>());
108 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<int(*)(int)>::value
>());
109 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<int*>::value
>());
110 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<VB
>::value
>());
111 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<VD
>::value
>());
112 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<enum_UDT
>::value
>());
113 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<mf2
>::value
>());
114 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<POD_UDT
>::value
>());
115 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<empty_UDT
>::value
>());
116 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<union_UDT
>::value
>());
117 do_check(tt::integral_constant
<std::size_t,::tt::alignment_of
<boost::detail::max_align
>::value
>());