is_nothrow_assignable.pass.cpp revision 933afa9761c1c1f916161278a99284d50a594939
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_nothrow_assignable 13 14#include <type_traits> 15 16template <class T, class U> 17void test_is_nothrow_assignable() 18{ 19 static_assert(( std::is_nothrow_assignable<T, U>::value), ""); 20} 21 22template <class T, class U> 23void test_is_not_nothrow_assignable() 24{ 25 static_assert((!std::is_nothrow_assignable<T, U>::value), ""); 26} 27 28struct A 29{ 30}; 31 32struct B 33{ 34 void operator=(A); 35}; 36 37int main() 38{ 39 test_is_nothrow_assignable<int&, int&> (); 40 test_is_nothrow_assignable<int&, int> (); 41#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 42 test_is_nothrow_assignable<int&, double> (); 43#endif 44 45 test_is_not_nothrow_assignable<int, int&> (); 46 test_is_not_nothrow_assignable<int, int> (); 47 test_is_not_nothrow_assignable<B, A> (); 48 test_is_not_nothrow_assignable<A, B> (); 49} 50