]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
Vendor import of libc++ trunk r256633:
[FreeBSD/FreeBSD.git] / test / std / utilities / meta / meta.unary / meta.unary.prop / is_assignable.pass.cpp
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
17 struct A
18 {
19 };
20
21 struct B
22 {
23     void operator=(A);
24 };
25
26 template <class T, class U>
27 void 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
35 template <class T, class U>
36 void 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
44 struct D;
45
46 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
47 struct C
48 {
49     template <class U>
50     D operator,(U&&);
51 };
52
53 struct E
54 {
55     C operator=(int);
56 };
57 #endif
58
59 template <typename T>
60 struct X { T t; };
61
62 int main()
63 {
64     test_is_assignable<int&, int&> ();
65     test_is_assignable<int&, int> ();
66     test_is_assignable<int&, double> ();
67     test_is_assignable<B, A> ();
68     test_is_assignable<void*&, void*> ();
69
70 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
71     test_is_assignable<E, int> ();
72
73     test_is_not_assignable<int, int&> ();
74     test_is_not_assignable<int, int> ();
75 #endif
76     test_is_not_assignable<A, B> ();
77     test_is_not_assignable<void, const void> ();
78     test_is_not_assignable<const void, const void> ();
79     test_is_not_assignable<int(), int> ();
80     
81 //  pointer to incomplete template type
82         test_is_assignable<X<D>*&, X<D>*> ();
83 }