xref: /llvm-project/libcxx/test/std/containers/sequences/array/aggregate.pass.cpp (revision 6900df37d26764b828dbc5c2f98a57abbce1583e)
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>
check_aggregate()18 void check_aggregate()
19 {
20     static_assert(std::is_aggregate<std::array<T, 0> >::value, "");
21     static_assert(std::is_aggregate<std::array<T, 1> >::value, "");
22     static_assert(std::is_aggregate<std::array<T, 2> >::value, "");
23     static_assert(std::is_aggregate<std::array<T, 3> >::value, "");
24     static_assert(std::is_aggregate<std::array<T, 4> >::value, "");
25 }
26 
27 struct Empty { };
28 struct Trivial { int i; int j; };
29 struct NonTrivial {
30     int i; int j;
NonTrivialNonTrivial31     NonTrivial(NonTrivial const&) { }
32 };
33 
main(int,char **)34 int main(int, char**)
35 {
36     check_aggregate<char>();
37     check_aggregate<int>();
38     check_aggregate<long>();
39     check_aggregate<float>();
40     check_aggregate<double>();
41     check_aggregate<long double>();
42     check_aggregate<Empty>();
43     check_aggregate<Trivial>();
44     check_aggregate<NonTrivial>();
45 
46     return 0;
47 }
48