Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // aligned_storage |
| 13 | |
| 14 | #include <type_traits> |
| 15 | |
| 16 | int main() |
| 17 | { |
| 18 | { |
| 19 | typedef std::aligned_storage<10, 1 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 20 | #if _LIBCPP_STD_VER > 11 |
| 21 | static_assert(std::is_same<std::aligned_storage_t<10, 1>, T1>::value, "" ); |
| 22 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 23 | static_assert(std::alignment_of<T1>::value == 1, ""); |
| 24 | static_assert(sizeof(T1) == 10, ""); |
| 25 | } |
| 26 | { |
| 27 | typedef std::aligned_storage<10, 2 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 28 | #if _LIBCPP_STD_VER > 11 |
| 29 | static_assert(std::is_same<std::aligned_storage_t<10, 2>, T1>::value, "" ); |
| 30 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 31 | static_assert(std::alignment_of<T1>::value == 2, ""); |
| 32 | static_assert(sizeof(T1) == 10, ""); |
| 33 | } |
| 34 | { |
| 35 | typedef std::aligned_storage<10, 4 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 36 | #if _LIBCPP_STD_VER > 11 |
| 37 | static_assert(std::is_same<std::aligned_storage_t<10, 4>, T1>::value, "" ); |
| 38 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 39 | static_assert(std::alignment_of<T1>::value == 4, ""); |
| 40 | static_assert(sizeof(T1) == 12, ""); |
| 41 | } |
| 42 | { |
| 43 | typedef std::aligned_storage<10, 8 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 44 | #if _LIBCPP_STD_VER > 11 |
| 45 | static_assert(std::is_same<std::aligned_storage_t<10, 8>, T1>::value, "" ); |
| 46 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 47 | static_assert(std::alignment_of<T1>::value == 8, ""); |
| 48 | static_assert(sizeof(T1) == 16, ""); |
| 49 | } |
| 50 | { |
| 51 | typedef std::aligned_storage<10, 16 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 52 | #if _LIBCPP_STD_VER > 11 |
| 53 | static_assert(std::is_same<std::aligned_storage_t<10, 16>, T1>::value, "" ); |
| 54 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 55 | static_assert(std::alignment_of<T1>::value == 16, ""); |
| 56 | static_assert(sizeof(T1) == 16, ""); |
| 57 | } |
| 58 | { |
| 59 | typedef std::aligned_storage<10, 32 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 60 | #if _LIBCPP_STD_VER > 11 |
| 61 | static_assert(std::is_same<std::aligned_storage_t<10, 32>, T1>::value, "" ); |
| 62 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 63 | static_assert(std::alignment_of<T1>::value == 32, ""); |
| 64 | static_assert(sizeof(T1) == 32, ""); |
| 65 | } |
| 66 | { |
| 67 | typedef std::aligned_storage<20, 32 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 68 | #if _LIBCPP_STD_VER > 11 |
| 69 | static_assert(std::is_same<std::aligned_storage_t<20, 32>, T1>::value, "" ); |
| 70 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 71 | static_assert(std::alignment_of<T1>::value == 32, ""); |
| 72 | static_assert(sizeof(T1) == 32, ""); |
| 73 | } |
| 74 | { |
| 75 | typedef std::aligned_storage<40, 32 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 76 | #if _LIBCPP_STD_VER > 11 |
| 77 | static_assert(std::is_same<std::aligned_storage_t<40, 32>, T1>::value, "" ); |
| 78 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 79 | static_assert(std::alignment_of<T1>::value == 32, ""); |
| 80 | static_assert(sizeof(T1) == 64, ""); |
| 81 | } |
| 82 | { |
| 83 | typedef std::aligned_storage<12, 16 >::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 84 | #if _LIBCPP_STD_VER > 11 |
| 85 | static_assert(std::is_same<std::aligned_storage_t<12, 16>, T1>::value, "" ); |
| 86 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 87 | static_assert(std::alignment_of<T1>::value == 16, ""); |
| 88 | static_assert(sizeof(T1) == 16, ""); |
| 89 | } |
| 90 | { |
| 91 | typedef std::aligned_storage<1>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 92 | #if _LIBCPP_STD_VER > 11 |
| 93 | static_assert(std::is_same<std::aligned_storage_t<1>, T1>::value, "" ); |
| 94 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 95 | static_assert(std::alignment_of<T1>::value == 1, ""); |
| 96 | static_assert(sizeof(T1) == 1, ""); |
| 97 | } |
| 98 | { |
| 99 | typedef std::aligned_storage<2>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 100 | #if _LIBCPP_STD_VER > 11 |
| 101 | static_assert(std::is_same<std::aligned_storage_t<2>, T1>::value, "" ); |
| 102 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 103 | static_assert(std::alignment_of<T1>::value == 2, ""); |
| 104 | static_assert(sizeof(T1) == 2, ""); |
| 105 | } |
| 106 | { |
| 107 | typedef std::aligned_storage<3>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 108 | #if _LIBCPP_STD_VER > 11 |
| 109 | static_assert(std::is_same<std::aligned_storage_t<3>, T1>::value, "" ); |
| 110 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 111 | static_assert(std::alignment_of<T1>::value == 2, ""); |
| 112 | static_assert(sizeof(T1) == 4, ""); |
| 113 | } |
| 114 | { |
| 115 | typedef std::aligned_storage<4>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 116 | #if _LIBCPP_STD_VER > 11 |
| 117 | static_assert(std::is_same<std::aligned_storage_t<4>, T1>::value, "" ); |
| 118 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 119 | static_assert(std::alignment_of<T1>::value == 4, ""); |
| 120 | static_assert(sizeof(T1) == 4, ""); |
| 121 | } |
| 122 | { |
| 123 | typedef std::aligned_storage<5>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 124 | #if _LIBCPP_STD_VER > 11 |
| 125 | static_assert(std::is_same<std::aligned_storage_t<5>, T1>::value, "" ); |
| 126 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 127 | static_assert(std::alignment_of<T1>::value == 4, ""); |
| 128 | static_assert(sizeof(T1) == 8, ""); |
| 129 | } |
| 130 | { |
| 131 | typedef std::aligned_storage<7>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 132 | #if _LIBCPP_STD_VER > 11 |
| 133 | static_assert(std::is_same<std::aligned_storage_t<7>, T1>::value, "" ); |
| 134 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 135 | static_assert(std::alignment_of<T1>::value == 4, ""); |
| 136 | static_assert(sizeof(T1) == 8, ""); |
| 137 | } |
| 138 | { |
| 139 | typedef std::aligned_storage<8>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 140 | #if _LIBCPP_STD_VER > 11 |
| 141 | static_assert(std::is_same<std::aligned_storage_t<8>, T1>::value, "" ); |
| 142 | #endif |
Howard Hinnant | 5544f7e | 2013-04-22 19:37:49 +0000 | [diff] [blame] | 143 | static_assert(std::alignment_of<T1>::value == 8, ""); |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 144 | static_assert(sizeof(T1) == 8, ""); |
| 145 | } |
| 146 | { |
| 147 | typedef std::aligned_storage<9>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 148 | #if _LIBCPP_STD_VER > 11 |
| 149 | static_assert(std::is_same<std::aligned_storage_t<9>, T1>::value, "" ); |
| 150 | #endif |
Howard Hinnant | 5544f7e | 2013-04-22 19:37:49 +0000 | [diff] [blame] | 151 | static_assert(std::alignment_of<T1>::value == 8, ""); |
| 152 | static_assert(sizeof(T1) == 16, ""); |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 153 | } |
| 154 | { |
| 155 | typedef std::aligned_storage<15>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 156 | #if _LIBCPP_STD_VER > 11 |
| 157 | static_assert(std::is_same<std::aligned_storage_t<15>, T1>::value, "" ); |
| 158 | #endif |
Howard Hinnant | 5544f7e | 2013-04-22 19:37:49 +0000 | [diff] [blame] | 159 | static_assert(std::alignment_of<T1>::value == 8, ""); |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 160 | static_assert(sizeof(T1) == 16, ""); |
| 161 | } |
| 162 | { |
| 163 | typedef std::aligned_storage<16>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 164 | #if _LIBCPP_STD_VER > 11 |
| 165 | static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" ); |
| 166 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 167 | static_assert(std::alignment_of<T1>::value == 16, ""); |
| 168 | static_assert(sizeof(T1) == 16, ""); |
| 169 | } |
| 170 | { |
| 171 | typedef std::aligned_storage<17>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 172 | #if _LIBCPP_STD_VER > 11 |
| 173 | static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" ); |
| 174 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 175 | static_assert(std::alignment_of<T1>::value == 16, ""); |
| 176 | static_assert(sizeof(T1) == 32, ""); |
| 177 | } |
| 178 | { |
| 179 | typedef std::aligned_storage<10>::type T1; |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 180 | #if _LIBCPP_STD_VER > 11 |
| 181 | static_assert(std::is_same<std::aligned_storage_t<10>, T1>::value, "" ); |
| 182 | #endif |
Howard Hinnant | 5544f7e | 2013-04-22 19:37:49 +0000 | [diff] [blame] | 183 | static_assert(std::alignment_of<T1>::value == 8, ""); |
| 184 | static_assert(sizeof(T1) == 16, ""); |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 185 | } |
| 186 | } |