/* (c) 2014 Glen Joseph Fernandes glenjofe at gmail dot com Distributed under the Boost Software License, Version 1.0. http://boost.org/LICENSE_1_0.txt */ #include #include #include #include template struct no_ref { typedef T type; }; template struct no_ref { typedef T type; }; #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template struct no_ref { typedef T type; }; #endif template struct no_extents { typedef T type; }; template struct no_extents { typedef typename no_extents::type type; }; template struct no_extents { typedef typename no_extents::type type; }; template struct no_const { typedef T type; }; template struct no_const { typedef T type; }; template struct no_volatile { typedef T type; }; template struct no_volatile { typedef T type; }; template struct no_cv { typedef typename no_volatile::type>::type type; }; template struct padded { char unit; typename no_cv::type>::type>::type object; }; template std::ptrdiff_t offset() { static padded p = padded(); return (char*)&p.object - &p.unit; } template void test_impl() { std::size_t result = boost::alignment:: alignment_of::value; BOOST_TEST_EQ(result, offset()); } template void test_reference() { test_impl(); test_impl(); #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) test_impl(); #endif } template void test_array() { test_reference(); test_reference(); test_impl(); } template void test_cv() { test_array(); test_array(); test_array(); test_array(); } template struct W1 { T t; }; template class W2 { public: T t; }; template union W3 { T t; }; template void test() { test_cv(); test_cv >(); test_cv >(); test_cv >(); } void test_integral() { test(); test(); test(); test(); test(); #if !defined(BOOST_NO_CXX11_CHAR16_T) test(); #endif #if !defined(BOOST_NO_CXX11_CHAR32_T) test(); #endif test(); test(); test(); test(); test(); test(); #if !defined(BOOST_NO_LONG_LONG) test(); test(); #endif } void test_floating_point() { test(); test(); test(); } void test_nullptr_t() { #if !defined(BOOST_NO_CXX11_NULLPTR) && \ !defined(BOOST_NO_CXX11_DECLTYPE) test(); #endif } class X; void test_pointer() { test(); test(); test(); test(); test(); } void test_member_pointer() { test(); test(); } enum E { v = 1 }; void test_enum() { test(); } struct S { }; class C { }; union U { }; void test_class() { test(); test(); test(); } int main() { test_integral(); test_floating_point(); test_nullptr_t(); test_pointer(); test_member_pointer(); test_enum(); test_class(); return boost::report_errors(); }