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 // has_nothrow_move_assign
     13 
     14 #include <type_traits>
     15 #include "test_macros.h"
     16 
     17 template <class T>
     18 void test_has_nothrow_assign()
     19 {
     20     static_assert( std::is_nothrow_move_assignable<T>::value, "");
     21 #if TEST_STD_VER > 14
     22     static_assert( std::is_nothrow_move_assignable_v<T>, "");
     23 #endif
     24 }
     25 
     26 template <class T>
     27 void test_has_not_nothrow_assign()
     28 {
     29     static_assert(!std::is_nothrow_move_assignable<T>::value, "");
     30 #if TEST_STD_VER > 14
     31     static_assert(!std::is_nothrow_move_assignable_v<T>, "");
     32 #endif
     33 }
     34 
     35 class Empty
     36 {
     37 };
     38 
     39 struct NotEmpty
     40 {
     41     virtual ~NotEmpty();
     42 };
     43 
     44 union Union {};
     45 
     46 struct bit_zero
     47 {
     48     int :  0;
     49 };
     50 
     51 struct A
     52 {
     53     A& operator=(const A&);
     54 };
     55 
     56 int main()
     57 {
     58     test_has_nothrow_assign<int&>();
     59     test_has_nothrow_assign<Union>();
     60     test_has_nothrow_assign<Empty>();
     61     test_has_nothrow_assign<int>();
     62     test_has_nothrow_assign<double>();
     63     test_has_nothrow_assign<int*>();
     64     test_has_nothrow_assign<const int*>();
     65     test_has_nothrow_assign<NotEmpty>();
     66     test_has_nothrow_assign<bit_zero>();
     67 
     68     test_has_not_nothrow_assign<void>();
     69     test_has_not_nothrow_assign<A>();
     70 }
     71