// (C) Copyright John Maddock 2000. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifdef TEST_STD # include # include // max_align and long_long_type #else # include # include # include #endif #include "test.hpp" #include "check_integral_constant.hpp" template union must_be_pod { int i; T t; }; template inline void no_unused_warning(const volatile T&) { } #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(BOOST_INTEL) #pragma GCC diagnostic ignored "-Wmissing-braces" #endif template void do_check(const T&) { typedef typename tt::aligned_storage::type t1; t1 as1 = { 0, }; must_be_pod pod1; no_unused_warning(as1); no_unused_warning(pod1); BOOST_TEST_MESSAGE(typeid(t1).name()); BOOST_CHECK(::tt::alignment_of::value == T::value); BOOST_CHECK(sizeof(t1) == T::value); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_CHECK(::tt::is_pod::value == true); #endif typedef typename tt::aligned_storage::type t2; t2 as2 = { 0, }; must_be_pod pod2; no_unused_warning(as2); no_unused_warning(pod2); BOOST_TEST_MESSAGE(typeid(t2).name()); BOOST_CHECK(::tt::alignment_of::value == T::value); BOOST_CHECK(sizeof(t2) == T::value*2); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_CHECK(::tt::is_pod::value == true); #endif #ifndef TEST_STD // Non-Tr1 behaviour: typedef typename tt::aligned_storage(0UL)>::type t3; t3 as3 = { 0, }; must_be_pod pod3; no_unused_warning(as3); no_unused_warning(pod3); BOOST_TEST_MESSAGE(typeid(t3).name()); BOOST_CHECK(::tt::alignment_of::value == ::tt::alignment_of< ::boost::detail::max_align>::value); BOOST_CHECK((sizeof(t3) % T::value) == 0); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_CHECK(::tt::is_pod::value == true); #endif BOOST_CHECK(as3.address() == &as3); const t3 as4 = { 0, }; BOOST_CHECK(as4.address() == static_cast(&as4)); #endif } TT_TEST_BEGIN(type_with_alignment) do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); #ifdef BOOST_HAS_LONG_LONG do_check(tt::integral_constant::value>()); #endif #ifdef BOOST_HAS_MS_INT64 do_check(tt::integral_constant::value>()); #endif do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); do_check(tt::integral_constant::value>()); TT_TEST_END