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 // libc++ doesn't implement std::is_aggregate on GCC 5 and GCC 6.
15 // UNSUPPORTED: libc++ && gcc-5
16 // UNSUPPORTED: libc++ && gcc-6
17 
18 #include <array>
19 #include <type_traits>
20 
21 template <typename T>
check_aggregate()22 void check_aggregate()
23 {
24     static_assert(std::is_aggregate<std::array<T, 0> >::value, "");
25     static_assert(std::is_aggregate<std::array<T, 1> >::value, "");
26     static_assert(std::is_aggregate<std::array<T, 2> >::value, "");
27     static_assert(std::is_aggregate<std::array<T, 3> >::value, "");
28     static_assert(std::is_aggregate<std::array<T, 4> >::value, "");
29 }
30 
31 struct Empty { };
32 struct Trivial { int i; int j; };
33 struct NonTrivial {
34     int i; int j;
NonTrivialNonTrivial35     NonTrivial(NonTrivial const&) { }
36 };
37 
main(int,char **)38 int main(int, char**)
39 {
40     check_aggregate<char>();
41     check_aggregate<int>();
42     check_aggregate<long>();
43     check_aggregate<float>();
44     check_aggregate<double>();
45     check_aggregate<long double>();
46     check_aggregate<Empty>();
47     check_aggregate<Trivial>();
48     check_aggregate<NonTrivial>();
49 
50     return 0;
51 }
52