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 // type_traits
11
12 // aligned_union<size_t Len, class ...Types>
13
14 #include <type_traits>
15
main()16 int main()
17 {
18 #ifndef _LIBCPP_HAS_NO_VARIADICS
19 {
20 typedef std::aligned_union<10, char >::type T1;
21 #if _LIBCPP_STD_VER > 11
22 static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" );
23 #endif
24 static_assert(std::alignment_of<T1>::value == 1, "");
25 static_assert(sizeof(T1) == 10, "");
26 }
27 {
28 typedef std::aligned_union<10, short >::type T1;
29 #if _LIBCPP_STD_VER > 11
30 static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" );
31 #endif
32 static_assert(std::alignment_of<T1>::value == 2, "");
33 static_assert(sizeof(T1) == 10, "");
34 }
35 {
36 typedef std::aligned_union<10, int >::type T1;
37 #if _LIBCPP_STD_VER > 11
38 static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" );
39 #endif
40 static_assert(std::alignment_of<T1>::value == 4, "");
41 static_assert(sizeof(T1) == 12, "");
42 }
43 {
44 typedef std::aligned_union<10, double >::type T1;
45 #if _LIBCPP_STD_VER > 11
46 static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" );
47 #endif
48 static_assert(std::alignment_of<T1>::value == 8, "");
49 static_assert(sizeof(T1) == 16, "");
50 }
51 {
52 typedef std::aligned_union<10, short, char >::type T1;
53 #if _LIBCPP_STD_VER > 11
54 static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" );
55 #endif
56 static_assert(std::alignment_of<T1>::value == 2, "");
57 static_assert(sizeof(T1) == 10, "");
58 }
59 {
60 typedef std::aligned_union<10, char, short >::type T1;
61 #if _LIBCPP_STD_VER > 11
62 static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" );
63 #endif
64 static_assert(std::alignment_of<T1>::value == 2, "");
65 static_assert(sizeof(T1) == 10, "");
66 }
67 {
68 typedef std::aligned_union<2, int, char, short >::type T1;
69 #if _LIBCPP_STD_VER > 11
70 static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" );
71 #endif
72 static_assert(std::alignment_of<T1>::value == 4, "");
73 static_assert(sizeof(T1) == 4, "");
74 }
75 {
76 typedef std::aligned_union<2, char, int, short >::type T1;
77 #if _LIBCPP_STD_VER > 11
78 static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" );
79 #endif
80 static_assert(std::alignment_of<T1>::value == 4, "");
81 static_assert(sizeof(T1) == 4, "");
82 }
83 {
84 typedef std::aligned_union<2, char, short, int >::type T1;
85 #if _LIBCPP_STD_VER > 11
86 static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" );
87 #endif
88 static_assert(std::alignment_of<T1>::value == 4, "");
89 static_assert(sizeof(T1) == 4, "");
90 }
91 #endif
92 }
93