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 // Issue 3034 added:
17 // The member typedef type shall be a trivial standard-layout type.
18
19 #include <type_traits>
20
21 #include "test_macros.h"
22
main()23 int main()
24 {
25 {
26 typedef std::aligned_union<10, char >::type T1;
27 #if TEST_STD_VER > 11
28 static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" );
29 #endif
30 static_assert(std::is_trivial<T1>::value, "");
31 static_assert(std::is_standard_layout<T1>::value, "");
32 static_assert(std::alignment_of<T1>::value == 1, "");
33 static_assert(sizeof(T1) == 10, "");
34 }
35 {
36 typedef std::aligned_union<10, short >::type T1;
37 #if TEST_STD_VER > 11
38 static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" );
39 #endif
40 static_assert(std::is_trivial<T1>::value, "");
41 static_assert(std::is_standard_layout<T1>::value, "");
42 static_assert(std::alignment_of<T1>::value == 2, "");
43 static_assert(sizeof(T1) == 10, "");
44 }
45 {
46 typedef std::aligned_union<10, int >::type T1;
47 #if TEST_STD_VER > 11
48 static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" );
49 #endif
50 static_assert(std::is_trivial<T1>::value, "");
51 static_assert(std::is_standard_layout<T1>::value, "");
52 static_assert(std::alignment_of<T1>::value == 4, "");
53 static_assert(sizeof(T1) == 12, "");
54 }
55 {
56 typedef std::aligned_union<10, double >::type T1;
57 #if TEST_STD_VER > 11
58 static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" );
59 #endif
60 static_assert(std::is_trivial<T1>::value, "");
61 static_assert(std::is_standard_layout<T1>::value, "");
62 static_assert(std::alignment_of<T1>::value == 8, "");
63 static_assert(sizeof(T1) == 16, "");
64 }
65 {
66 typedef std::aligned_union<10, short, char >::type T1;
67 #if TEST_STD_VER > 11
68 static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" );
69 #endif
70 static_assert(std::is_trivial<T1>::value, "");
71 static_assert(std::is_standard_layout<T1>::value, "");
72 static_assert(std::alignment_of<T1>::value == 2, "");
73 static_assert(sizeof(T1) == 10, "");
74 }
75 {
76 typedef std::aligned_union<10, char, short >::type T1;
77 #if TEST_STD_VER > 11
78 static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" );
79 #endif
80 static_assert(std::is_trivial<T1>::value, "");
81 static_assert(std::is_standard_layout<T1>::value, "");
82 static_assert(std::alignment_of<T1>::value == 2, "");
83 static_assert(sizeof(T1) == 10, "");
84 }
85 {
86 typedef std::aligned_union<2, int, char, short >::type T1;
87 #if TEST_STD_VER > 11
88 static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" );
89 #endif
90 static_assert(std::is_trivial<T1>::value, "");
91 static_assert(std::is_standard_layout<T1>::value, "");
92 static_assert(std::alignment_of<T1>::value == 4, "");
93 static_assert(sizeof(T1) == 4, "");
94 }
95 {
96 typedef std::aligned_union<2, char, int, short >::type T1;
97 #if TEST_STD_VER > 11
98 static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" );
99 #endif
100 static_assert(std::is_trivial<T1>::value, "");
101 static_assert(std::is_standard_layout<T1>::value, "");
102 static_assert(std::alignment_of<T1>::value == 4, "");
103 static_assert(sizeof(T1) == 4, "");
104 }
105 {
106 typedef std::aligned_union<2, char, short, int >::type T1;
107 #if TEST_STD_VER > 11
108 static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" );
109 #endif
110 static_assert(std::is_trivial<T1>::value, "");
111 static_assert(std::is_standard_layout<T1>::value, "");
112 static_assert(std::alignment_of<T1>::value == 4, "");
113 static_assert(sizeof(T1) == 4, "");
114 }
115 }
116