is_assignable.pass.cpp revision 01afa5c6e407e985d9643707d7b7ab1384bd9317
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_assignable 13 14#include <type_traits> 15 16struct A 17{ 18}; 19 20struct B 21{ 22 void operator=(A); 23}; 24 25template <class T, class U> 26void test_is_assignable() 27{ 28 static_assert(( std::is_assignable<T, U>::value), ""); 29} 30 31template <class T, class U> 32void test_is_not_assignable() 33{ 34 static_assert((!std::is_assignable<T, U>::value), ""); 35} 36 37struct D; 38 39struct C 40{ 41 template <class U> 42 D operator,(U&&); 43}; 44 45struct E 46{ 47 C operator=(int); 48}; 49 50int main() 51{ 52 test_is_assignable<int&, int&> (); 53 test_is_assignable<int&, int> (); 54 test_is_assignable<int&, double> (); 55 test_is_assignable<B, A> (); 56 test_is_assignable<void*&, void*> (); 57 test_is_assignable<E, int> (); 58 59#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 60 test_is_not_assignable<int, int&> (); 61 test_is_not_assignable<int, int> (); 62#endif 63 test_is_not_assignable<A, B> (); 64 test_is_not_assignable<void, const void> (); 65 test_is_not_assignable<const void, const void> (); 66 test_is_not_assignable<int(), int> (); 67} 68