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 
     16 template <class T>
     17 void test_is_copy_assignable()
     18 {
     19     static_assert(( std::is_copy_assignable<T>::value), "");
     20 }
     21 
     22 template <class T>
     23 void test_is_not_copy_assignable()
     24 {
     25     static_assert((!std::is_copy_assignable<T>::value), "");
     26 }
     27 
     28 class Empty
     29 {
     30 };
     31 
     32 class NotEmpty
     33 {
     34 public:
     35     virtual ~NotEmpty();
     36 };
     37 
     38 union Union {};
     39 
     40 struct bit_zero
     41 {
     42     int :  0;
     43 };
     44 
     45 struct A
     46 {
     47     A();
     48 };
     49 
     50 class B
     51 {
     52     B& operator=(const B&);
     53 };
     54 
     55 int main()
     56 {
     57     test_is_copy_assignable<int> ();
     58     test_is_copy_assignable<int&> ();
     59     test_is_copy_assignable<A> ();
     60     test_is_copy_assignable<bit_zero> ();
     61     test_is_copy_assignable<Union> ();
     62     test_is_copy_assignable<NotEmpty> ();
     63     test_is_copy_assignable<Empty> ();
     64 
     65 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     66     test_is_not_copy_assignable<const int> ();
     67     test_is_not_copy_assignable<int[]> ();
     68     test_is_not_copy_assignable<int[3]> ();
     69 #endif
     70 #if __has_feature(cxx_access_control_sfinae)
     71     test_is_not_copy_assignable<B> ();
     72 #endif
     73     test_is_not_copy_assignable<void> ();
     74 }
     75