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_abstract.pass.cpp
blobee6a12e4bd87ebd42218108740be7c01391f3825
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 // type_traits
11 // is_abstract
13 #include <type_traits>
14 #include "test_macros.h"
16 template <class T>
17 void test_is_abstract()
19 static_assert( std::is_abstract<T>::value, "");
20 static_assert( std::is_abstract<const T>::value, "");
21 static_assert( std::is_abstract<volatile T>::value, "");
22 static_assert( std::is_abstract<const volatile T>::value, "");
23 #if TEST_STD_VER > 14
24 static_assert( std::is_abstract_v<T>, "");
25 static_assert( std::is_abstract_v<const T>, "");
26 static_assert( std::is_abstract_v<volatile T>, "");
27 static_assert( std::is_abstract_v<const volatile T>, "");
28 #endif
31 template <class T>
32 void test_is_not_abstract()
34 static_assert(!std::is_abstract<T>::value, "");
35 static_assert(!std::is_abstract<const T>::value, "");
36 static_assert(!std::is_abstract<volatile T>::value, "");
37 static_assert(!std::is_abstract<const volatile T>::value, "");
38 #if TEST_STD_VER > 14
39 static_assert(!std::is_abstract_v<T>, "");
40 static_assert(!std::is_abstract_v<const T>, "");
41 static_assert(!std::is_abstract_v<volatile T>, "");
42 static_assert(!std::is_abstract_v<const volatile T>, "");
43 #endif
46 class Empty
50 class NotEmpty
52 virtual ~NotEmpty();
55 union Union {};
57 struct bit_zero
59 int : 0;
62 class Abstract
64 virtual ~Abstract() = 0;
67 template <class>
68 struct AbstractTemplate {
69 virtual void test() = 0;
72 template <>
73 struct AbstractTemplate<double> {};
75 int main(int, char**)
77 test_is_not_abstract<void>();
78 test_is_not_abstract<int&>();
79 test_is_not_abstract<int>();
80 test_is_not_abstract<double>();
81 test_is_not_abstract<int*>();
82 test_is_not_abstract<const int*>();
83 test_is_not_abstract<char[3]>();
84 test_is_not_abstract<char[]>();
85 test_is_not_abstract<Union>();
86 test_is_not_abstract<Empty>();
87 test_is_not_abstract<bit_zero>();
88 test_is_not_abstract<NotEmpty>();
90 test_is_abstract<Abstract>();
91 test_is_abstract<AbstractTemplate<int> >();
92 test_is_not_abstract<AbstractTemplate<double> >();
94 return 0;