Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_aggregate.pass.cpp
blob277e154712f35a2bf973cc975648d297759a2d73
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <type_traits>
13 // template <class T> struct is_aggregate;
14 // template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value;
16 #include <type_traits>
17 #include "test_macros.h"
19 template <class T>
20 void test_true()
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>, "");
32 template <class T>
33 void test_false()
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>, "");
45 struct Aggregate {};
46 struct HasCons { HasCons(int); };
47 struct HasPriv {
48 void PreventUnusedPrivateMemberWarning();
49 private:
50 int x;
52 struct Union { int x; void* y; };
55 int main(int, char**)
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>();
69 test_true<Aggregate>();
70 test_true<Aggregate[]>();
71 test_true<Aggregate[42][101]>();
72 test_true<Union>();
75 return 0;