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_final.pass.cpp
blob7278cf8ba092e4696f9e35accf6f20e3834e86c6
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
10 // type_traits
12 // is_final
14 #include <type_traits>
15 #include "test_macros.h"
17 struct P final { };
18 union U1 { };
19 union U2 final { };
21 template <class T>
22 void test_is_final()
24 static_assert( std::is_final<T>::value, "");
25 static_assert( std::is_final<const T>::value, "");
26 static_assert( std::is_final<volatile T>::value, "");
27 static_assert( std::is_final<const volatile T>::value, "");
28 #if TEST_STD_VER > 14
29 static_assert( std::is_final_v<T>, "");
30 static_assert( std::is_final_v<const T>, "");
31 static_assert( std::is_final_v<volatile T>, "");
32 static_assert( std::is_final_v<const volatile T>, "");
33 #endif
36 template <class T>
37 void test_is_not_final()
39 static_assert(!std::is_final<T>::value, "");
40 static_assert(!std::is_final<const T>::value, "");
41 static_assert(!std::is_final<volatile T>::value, "");
42 static_assert(!std::is_final<const volatile T>::value, "");
43 #if TEST_STD_VER > 14
44 static_assert(!std::is_final_v<T>, "");
45 static_assert(!std::is_final_v<const T>, "");
46 static_assert(!std::is_final_v<volatile T>, "");
47 static_assert(!std::is_final_v<const volatile T>, "");
48 #endif
51 int main(int, char**)
53 test_is_not_final<int>();
54 test_is_not_final<int*>();
55 test_is_final <P>();
56 test_is_not_final<P*>();
57 test_is_not_final<U1>();
58 test_is_not_final<U1*>();
59 test_is_final <U2>();
60 test_is_not_final<U2*>();
62 return 0;