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 
16 struct A
17 {
18 };
19 
20 struct B
21 {
22     void operator=(A);
23 };
24 
25 template <class T, class U>
26 void test_is_assignable()
27 {
28     static_assert(( std::is_assignable<T, U>::value), "");
29 }
30 
31 template <class T, class U>
32 void test_is_not_assignable()
33 {
34     static_assert((!std::is_assignable<T, U>::value), "");
35 }
36 
37 struct D;
38 
39 struct C
40 {
41     template <class U>
42     D operator,(U&&);
43 };
44 
45 struct E
46 {
47     C operator=(int);
48 };
49 
50 int 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