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
), "");
46 #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
47 struct TEST_ALIGNAS(__STDCPP_DEFAULT_NEW_ALIGNMENT__
* 2) TestType1
{
51 struct TEST_ALIGNAS(__STDCPP_DEFAULT_NEW_ALIGNMENT__
* 2) TestType2
{
55 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t
) * 2) TestType1
{
59 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t
) * 2) TestType2
{
64 int main(int, char**) {
68 test_type
<long double>();
70 #if TEST_STD_VER >= 11
71 test_type
<std::max_align_t
>();
73 test_type
<TestType1
>();
74 test_type
<TestType2
>();