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     static_assert( std::is_aggregate<T>::value, "");
23     static_assert( std::is_aggregate<const T>::value, "");
24     static_assert( std::is_aggregate<volatile T>::value, "");
25     static_assert( std::is_aggregate<const volatile T>::value, "");
26     static_assert( std::is_aggregate_v<T>, "");
27     static_assert( std::is_aggregate_v<const T>, "");
28     static_assert( std::is_aggregate_v<volatile T>, "");
29     static_assert( std::is_aggregate_v<const volatile T>, "");
30 }
31 
32 template <class T>
test_false()33 void test_false()
34 {
35     static_assert(!std::is_aggregate<T>::value, "");
36     static_assert(!std::is_aggregate<const T>::value, "");
37     static_assert(!std::is_aggregate<volatile T>::value, "");
38     static_assert(!std::is_aggregate<const volatile T>::value, "");
39     static_assert(!std::is_aggregate_v<T>, "");
40     static_assert(!std::is_aggregate_v<const T>, "");
41     static_assert(!std::is_aggregate_v<volatile T>, "");
42     static_assert(!std::is_aggregate_v<const volatile T>, "");
43 }
44 
45 struct Aggregate {};
46 struct HasCons { HasCons(int); };
47 struct HasPriv {
48   void PreventUnusedPrivateMemberWarning();
49 private:
50   int x;
51 };
52 struct Union { int x; void* y; };
53 
54 
main(int,char **)55 int main(int, char**)
56 {
57   {
58     test_false<void>();
59     test_false<int>();
60     test_false<void*>();
61     test_false<void()>();
62     test_false<void() const>();
63     test_false<void(Aggregate::*)(int) const>();
64     test_false<Aggregate&>();
65     test_false<HasCons>();
66     test_false<HasPriv>();
67   }
68   {
69     test_true<Aggregate>();
70     test_true<Aggregate[]>();
71     test_true<Aggregate[42][101]>();
72     test_true<Union>();
73   }
74 
75   return 0;
76 }
77