1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03 11 12 // type_traits 13 14 // aligned_union<size_t Len, class ...Types> 15 16 #include <type_traits> 17 18 #include "test_macros.h" 19 20 int main() 21 { 22 { 23 typedef std::aligned_union<10, char >::type T1; 24 #if TEST_STD_VER > 11 25 static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" ); 26 #endif 27 static_assert(std::alignment_of<T1>::value == 1, ""); 28 static_assert(sizeof(T1) == 10, ""); 29 } 30 { 31 typedef std::aligned_union<10, short >::type T1; 32 #if TEST_STD_VER > 11 33 static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" ); 34 #endif 35 static_assert(std::alignment_of<T1>::value == 2, ""); 36 static_assert(sizeof(T1) == 10, ""); 37 } 38 { 39 typedef std::aligned_union<10, int >::type T1; 40 #if TEST_STD_VER > 11 41 static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" ); 42 #endif 43 static_assert(std::alignment_of<T1>::value == 4, ""); 44 static_assert(sizeof(T1) == 12, ""); 45 } 46 { 47 typedef std::aligned_union<10, double >::type T1; 48 #if TEST_STD_VER > 11 49 static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" ); 50 #endif 51 static_assert(std::alignment_of<T1>::value == 8, ""); 52 static_assert(sizeof(T1) == 16, ""); 53 } 54 { 55 typedef std::aligned_union<10, short, char >::type T1; 56 #if TEST_STD_VER > 11 57 static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" ); 58 #endif 59 static_assert(std::alignment_of<T1>::value == 2, ""); 60 static_assert(sizeof(T1) == 10, ""); 61 } 62 { 63 typedef std::aligned_union<10, char, short >::type T1; 64 #if TEST_STD_VER > 11 65 static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" ); 66 #endif 67 static_assert(std::alignment_of<T1>::value == 2, ""); 68 static_assert(sizeof(T1) == 10, ""); 69 } 70 { 71 typedef std::aligned_union<2, int, char, short >::type T1; 72 #if TEST_STD_VER > 11 73 static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" ); 74 #endif 75 static_assert(std::alignment_of<T1>::value == 4, ""); 76 static_assert(sizeof(T1) == 4, ""); 77 } 78 { 79 typedef std::aligned_union<2, char, int, short >::type T1; 80 #if TEST_STD_VER > 11 81 static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" ); 82 #endif 83 static_assert(std::alignment_of<T1>::value == 4, ""); 84 static_assert(sizeof(T1) == 4, ""); 85 } 86 { 87 typedef std::aligned_union<2, char, short, int >::type T1; 88 #if TEST_STD_VER > 11 89 static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" ); 90 #endif 91 static_assert(std::alignment_of<T1>::value == 4, ""); 92 static_assert(sizeof(T1) == 4, ""); 93 } 94 } 95