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 // UNSUPPORTED: c++03, c++11, c++14
10
11 // <type_traits>
12
13 // template <class T> struct is_aggregate;
14 // template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value;
15
16 #include <type_traits>
17 #include "test_macros.h"
18
19 template <class T>
test_true()20 void test_true()
21 {
22 #if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
23 static_assert( std::is_aggregate<T>::value, "");
24 static_assert( std::is_aggregate<const T>::value, "");
25 static_assert( std::is_aggregate<volatile T>::value, "");
26 static_assert( std::is_aggregate<const volatile T>::value, "");
27 static_assert( std::is_aggregate_v<T>, "");
28 static_assert( std::is_aggregate_v<const T>, "");
29 static_assert( std::is_aggregate_v<volatile T>, "");
30 static_assert( std::is_aggregate_v<const volatile T>, "");
31 #endif
32 }
33
34 template <class T>
test_false()35 void test_false()
36 {
37 #if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE)
38 static_assert(!std::is_aggregate<T>::value, "");
39 static_assert(!std::is_aggregate<const T>::value, "");
40 static_assert(!std::is_aggregate<volatile T>::value, "");
41 static_assert(!std::is_aggregate<const volatile T>::value, "");
42 static_assert(!std::is_aggregate_v<T>, "");
43 static_assert(!std::is_aggregate_v<const T>, "");
44 static_assert(!std::is_aggregate_v<volatile T>, "");
45 static_assert(!std::is_aggregate_v<const volatile T>, "");
46 #endif
47 }
48
49 struct Aggregate {};
50 struct HasCons { HasCons(int); };
51 struct HasPriv {
52 void PreventUnusedPrivateMemberWarning();
53 private:
54 int x;
55 };
56 struct Union { int x; void* y; };
57
58
main(int,char **)59 int main(int, char**)
60 {
61 {
62 test_false<void>();
63 test_false<int>();
64 test_false<void*>();
65 test_false<void()>();
66 test_false<void() const>();
67 test_false<void(Aggregate::*)(int) const>();
68 test_false<Aggregate&>();
69 test_false<HasCons>();
70 test_false<HasPriv>();
71 }
72 {
73 test_true<Aggregate>();
74 test_true<Aggregate[]>();
75 test_true<Aggregate[42][101]>();
76 test_true<Union>();
77 }
78
79 return 0;
80 }
81