1 | //===----------------------------------------------------------------------===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // Make sure std::array is an aggregate type. |
10 | // We can only check this in C++17 and above, because we don't have the |
11 | // trait before that. |
12 | // UNSUPPORTED: c++03, c++11, c++14 |
13 | |
14 | #include <array> |
15 | #include <type_traits> |
16 | |
17 | template <typename T> |
18 | void check_aggregate() { |
19 | static_assert(std::is_aggregate<std::array<T, 0> >::value, "" ); |
20 | static_assert(std::is_aggregate<std::array<T, 1> >::value, "" ); |
21 | static_assert(std::is_aggregate<std::array<T, 2> >::value, "" ); |
22 | static_assert(std::is_aggregate<std::array<T, 3> >::value, "" ); |
23 | static_assert(std::is_aggregate<std::array<T, 4> >::value, "" ); |
24 | } |
25 | |
26 | struct Empty {}; |
27 | struct Trivial { |
28 | int i; |
29 | int j; |
30 | }; |
31 | struct NonTrivial { |
32 | int i; |
33 | int j; |
34 | NonTrivial(NonTrivial const&) {} |
35 | }; |
36 | |
37 | int main(int, char**) { |
38 | check_aggregate<char>(); |
39 | check_aggregate<int>(); |
40 | check_aggregate<long>(); |
41 | check_aggregate<float>(); |
42 | check_aggregate<double>(); |
43 | check_aggregate<long double>(); |
44 | check_aggregate<Empty>(); |
45 | check_aggregate<Trivial>(); |
46 | check_aggregate<NonTrivial>(); |
47 | |
48 | return 0; |
49 | } |
50 | |