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