Marshall Clow | ebd6c2b | 2014-03-05 03:39:25 +0000 | [diff] [blame] | 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 | |
Marshall Clow | 24b29a0 | 2014-03-05 17:58:48 +0000 | [diff] [blame] | 16 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | ebd6c2b | 2014-03-05 03:39:25 +0000 | [diff] [blame] | 17 | |
| 18 | struct P final { }; |
| 19 | union U1 { }; |
| 20 | union U2 final { }; |
| 21 | |
| 22 | template <class T> |
| 23 | void 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 | |
| 31 | template <class T> |
| 32 | void 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, ""); |
Marshall Clow | ebd6c2b | 2014-03-05 03:39:25 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | int 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 |
| 52 | int main () {} |
| 53 | #endif |