Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_assignable.pass.cpp
blob8e5e2cc6e0477bc206f7b6f93ad2a6d4a561c399
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // type_traits
11 // is_assignable
13 #include <type_traits>
14 #include "test_macros.h"
16 struct A
20 struct B
22 void operator=(A);
25 template <class T, class U>
26 void test_is_assignable()
28 static_assert(( std::is_assignable<T, U>::value), "");
29 #if TEST_STD_VER > 14
30 static_assert( std::is_assignable_v<T, U>, "");
31 #endif
34 template <class T, class U>
35 void test_is_not_assignable()
37 static_assert((!std::is_assignable<T, U>::value), "");
38 #if TEST_STD_VER > 14
39 static_assert( !std::is_assignable_v<T, U>, "");
40 #endif
43 struct D;
45 #if TEST_STD_VER >= 11
46 struct C
48 template <class U>
49 D operator,(U&&);
52 struct E
54 C operator=(int);
56 #endif
58 template <typename T>
59 struct X { T t; };
61 int main(int, char**)
63 test_is_assignable<int&, int&> ();
64 test_is_assignable<int&, int> ();
65 test_is_assignable<int&, double> ();
66 test_is_assignable<B, A> ();
67 test_is_assignable<void*&, void*> ();
69 #if TEST_STD_VER >= 11
70 test_is_assignable<E, int> ();
72 test_is_not_assignable<int, int&> ();
73 test_is_not_assignable<int, int> ();
74 #endif
75 test_is_not_assignable<A, B> ();
76 test_is_not_assignable<void, const void> ();
77 test_is_not_assignable<const void, const void> ();
78 test_is_not_assignable<int(), int> ();
80 // pointer to incomplete template type
81 test_is_assignable<X<D>*&, X<D>*> ();
83 return 0;