is_final.pass.cpp revision 24b29a02f193db6437289e24fbe09fbf7b4bcfcb
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// is_final
13
14#include <type_traits>
15
16#if _LIBCPP_STD_VER > 11
17
18struct P final { };
19union U1 { };
20union U2 final { };
21
22template <class T>
23void test_is_final()
24{
25    static_assert( std::is_final<T>::value, "");
26    static_assert( std::is_final<const T>::value, "");
27    static_assert( std::is_final<volatile T>::value, "");
28    static_assert( std::is_final<const volatile T>::value, "");
29}
30
31template <class T>
32void test_is_not_final()
33{
34    static_assert(!std::is_final<T>::value, "");
35    static_assert(!std::is_final<const T>::value, "");
36    static_assert(!std::is_final<volatile T>::value, "");
37    static_assert(!std::is_final<const volatile T>::value, "");
38}
39
40int main ()
41{
42    test_is_not_final<int>();
43    test_is_not_final<int*>();
44    test_is_final    <P>();
45    test_is_not_final<P*>();
46    test_is_not_final<U1>();
47    test_is_not_final<U1*>();
48    test_is_final    <U2>();
49    test_is_not_final<U2*>();
50}
51#else
52int main () {}
53#endif
54