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#include "test_macros.h"
16
17struct A
18{
19};
20
21struct B
22{
23    void operator=(A);
24};
25
26template <class T, class U>
27void test_is_assignable()
28{
29    static_assert(( std::is_assignable<T, U>::value), "");
30#if TEST_STD_VER > 14
31    static_assert(  std::is_assignable_v<T, U>, "");
32#endif
33}
34
35template <class T, class U>
36void test_is_not_assignable()
37{
38    static_assert((!std::is_assignable<T, U>::value), "");
39#if TEST_STD_VER > 14
40    static_assert( !std::is_assignable_v<T, U>, "");
41#endif
42}
43
44struct D;
45
46#if TEST_STD_VER >= 11
47struct C
48{
49    template <class U>
50    D operator,(U&&);
51};
52
53struct E
54{
55    C operator=(int);
56};
57#endif
58
59template <typename T>
60struct X { T t; };
61
62struct Incomplete;
63
64int main()
65{
66    test_is_assignable<int&, int&> ();
67    test_is_assignable<int&, int> ();
68    test_is_assignable<int&, double> ();
69    test_is_assignable<B, A> ();
70    test_is_assignable<void*&, void*> ();
71
72#if TEST_STD_VER >= 11
73    test_is_assignable<E, int> ();
74
75    test_is_not_assignable<int, int&> ();
76    test_is_not_assignable<int, int> ();
77#endif
78    test_is_not_assignable<A, B> ();
79    test_is_not_assignable<void, const void> ();
80    test_is_not_assignable<const void, const void> ();
81    test_is_not_assignable<int(), int> ();
82
83//  pointer to incomplete template type
84	test_is_assignable<X<D>*&, X<D>*> ();
85}
86