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_nothrow_assignable.pass.cpp
blobbe1f016a4eb39e30b0facdb42dee9a23e297dced
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_nothrow_assignable
13 #include <type_traits>
14 #include "test_macros.h"
16 template <class T, class U>
17 void test_is_nothrow_assignable()
19 static_assert(( std::is_nothrow_assignable<T, U>::value), "");
20 #if TEST_STD_VER > 14
21 static_assert(( std::is_nothrow_assignable_v<T, U>), "");
22 #endif
25 template <class T, class U>
26 void test_is_not_nothrow_assignable()
28 static_assert((!std::is_nothrow_assignable<T, U>::value), "");
29 #if TEST_STD_VER > 14
30 static_assert((!std::is_nothrow_assignable_v<T, U>), "");
31 #endif
34 struct A
38 struct B
40 void operator=(A);
43 struct C
45 void operator=(C&); // not const
48 int main(int, char**)
50 test_is_nothrow_assignable<int&, int&> ();
51 test_is_nothrow_assignable<int&, int> ();
52 #if TEST_STD_VER >= 11
53 test_is_nothrow_assignable<int&, double> ();
54 #endif
56 test_is_not_nothrow_assignable<int, int&> ();
57 test_is_not_nothrow_assignable<int, int> ();
58 test_is_not_nothrow_assignable<B, A> ();
59 test_is_not_nothrow_assignable<A, B> ();
60 test_is_not_nothrow_assignable<C, C&> ();
62 return 0;