Home | History | Annotate | Download | only in meta.unary.prop
      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 #include "test_macros.h"
     16 
     17 #if _LIBCPP_STD_VER > 11
     18 
     19 struct P final { };
     20 union U1 { };
     21 union U2 final { };
     22 
     23 template <class T>
     24 void test_is_final()
     25 {
     26     static_assert( std::is_final<T>::value, "");
     27     static_assert( std::is_final<const T>::value, "");
     28     static_assert( std::is_final<volatile T>::value, "");
     29     static_assert( std::is_final<const volatile T>::value, "");
     30 #if TEST_STD_VER > 14
     31     static_assert( std::is_final_v<T>, "");
     32     static_assert( std::is_final_v<const T>, "");
     33     static_assert( std::is_final_v<volatile T>, "");
     34     static_assert( std::is_final_v<const volatile T>, "");
     35 #endif
     36 }
     37 
     38 template <class T>
     39 void test_is_not_final()
     40 {
     41     static_assert(!std::is_final<T>::value, "");
     42     static_assert(!std::is_final<const T>::value, "");
     43     static_assert(!std::is_final<volatile T>::value, "");
     44     static_assert(!std::is_final<const volatile T>::value, "");
     45 #if TEST_STD_VER > 14
     46     static_assert(!std::is_final_v<T>, "");
     47     static_assert(!std::is_final_v<const T>, "");
     48     static_assert(!std::is_final_v<volatile T>, "");
     49     static_assert(!std::is_final_v<const volatile T>, "");
     50 #endif
     51 }
     52 
     53 int main ()
     54 {
     55     test_is_not_final<int>();
     56     test_is_not_final<int*>();
     57     test_is_final    <P>();
     58     test_is_not_final<P*>();
     59     test_is_not_final<U1>();
     60     test_is_not_final<U1*>();
     61     test_is_final    <U2>();
     62     test_is_not_final<U2*>();
     63 }
     64 #else
     65 int main () {}
     66 #endif
     67