1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template <class T, size_t N >
14 // Test the size and alignment matches that of an array of a given type.
18 #include <type_traits>
21 #include "test_macros.h"
24 template <class T
, size_t Size
>
29 template <class T
, size_t Size
>
31 typedef T CArrayT
[Size
== 0 ? 1 : Size
];
32 typedef std::array
<T
, Size
> ArrayT
;
33 typedef MyArray
<T
, Size
== 0 ? 1 : Size
> MyArrayT
;
34 static_assert(sizeof(ArrayT
) == sizeof(CArrayT
), "");
35 static_assert(sizeof(ArrayT
) == sizeof(MyArrayT
), "");
36 static_assert(TEST_ALIGNOF(ArrayT
) == TEST_ALIGNOF(MyArrayT
), "");
37 #if defined(_LIBCPP_VERSION)
40 static_assert(sizeof(ArrayT
) == sizeof(a
.__elems_
), "");
41 static_assert(TEST_ALIGNOF(ArrayT
) == __alignof__(a
.__elems_
), "");
52 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t
) * 2) TestType1
{
56 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t
) * 2) TestType2
{
60 //static_assert(sizeof(void*) == 4, "");
62 int main(int, char**) {
66 test_type
<long double>();
67 test_type
<std::max_align_t
>();
68 test_type
<TestType1
>();
69 test_type
<TestType2
>();