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_copy_assignable
     13 
     14 #include <type_traits>
     15 #include "test_macros.h"
     16 
     17 template <class T>
     18 void test_is_copy_assignable()
     19 {
     20     static_assert(( std::is_copy_assignable<T>::value), "");
     21 #if TEST_STD_VER > 14
     22     static_assert(( std::is_copy_assignable_v<T>), "");
     23 #endif
     24 }
     25 
     26 template <class T>
     27 void test_is_not_copy_assignable()
     28 {
     29     static_assert((!std::is_copy_assignable<T>::value), "");
     30 #if TEST_STD_VER > 14
     31     static_assert((!std::is_copy_assignable_v<T>), "");
     32 #endif
     33 }
     34 
     35 class Empty
     36 {
     37 };
     38 
     39 class NotEmpty
     40 {
     41 public:
     42     virtual ~NotEmpty();
     43 };
     44 
     45 union Union {};
     46 
     47 struct bit_zero
     48 {
     49     int :  0;
     50 };
     51 
     52 struct A
     53 {
     54     A();
     55 };
     56 
     57 class B
     58 {
     59     B& operator=(const B&);
     60 };
     61 
     62 struct C
     63 {
     64     void operator=(C&);  // not const
     65 };
     66 
     67 int main()
     68 {
     69     test_is_copy_assignable<int> ();
     70     test_is_copy_assignable<int&> ();
     71     test_is_copy_assignable<A> ();
     72     test_is_copy_assignable<bit_zero> ();
     73     test_is_copy_assignable<Union> ();
     74     test_is_copy_assignable<NotEmpty> ();
     75     test_is_copy_assignable<Empty> ();
     76 
     77 #if TEST_STD_VER >= 11
     78     test_is_not_copy_assignable<const int> ();
     79     test_is_not_copy_assignable<int[]> ();
     80     test_is_not_copy_assignable<int[3]> ();
     81     test_is_not_copy_assignable<B> ();
     82 #endif
     83     test_is_not_copy_assignable<void> ();
     84     test_is_not_copy_assignable<C> ();
     85 }
     86