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_constructible.pass.cpp
blobad960d87f2b8223fb988168bbe0af6861f35f671
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 // template <class T, class... Args>
12 // struct is_nothrow_constructible;
14 #include <type_traits>
15 #include "test_macros.h"
17 #include "common.h"
19 template <class T>
20 void test_is_nothrow_constructible()
22 static_assert(( std::is_nothrow_constructible<T>::value), "");
23 #if TEST_STD_VER > 14
24 static_assert(( std::is_nothrow_constructible_v<T>), "");
25 #endif
28 template <class T, class A0>
29 void test_is_nothrow_constructible()
31 static_assert(( std::is_nothrow_constructible<T, A0>::value), "");
32 #if TEST_STD_VER > 14
33 static_assert(( std::is_nothrow_constructible_v<T, A0>), "");
34 #endif
37 template <class T>
38 void test_is_not_nothrow_constructible()
40 static_assert((!std::is_nothrow_constructible<T>::value), "");
41 #if TEST_STD_VER > 14
42 static_assert((!std::is_nothrow_constructible_v<T>), "");
43 #endif
46 template <class T, class A0>
47 void test_is_not_nothrow_constructible()
49 static_assert((!std::is_nothrow_constructible<T, A0>::value), "");
50 #if TEST_STD_VER > 14
51 static_assert((!std::is_nothrow_constructible_v<T, A0>), "");
52 #endif
55 template <class T, class A0, class A1>
56 void test_is_not_nothrow_constructible()
58 static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), "");
59 #if TEST_STD_VER > 14
60 static_assert((!std::is_nothrow_constructible_v<T, A0, A1>), "");
61 #endif
64 struct C
66 C(C&); // not const
67 void operator=(C&); // not const
70 #if TEST_STD_VER >= 11
71 struct Tuple {
72 Tuple(Empty&&) noexcept {}
74 #endif
76 int main(int, char**)
78 test_is_nothrow_constructible<int> ();
79 test_is_nothrow_constructible<int, const int&> ();
80 test_is_nothrow_constructible<Empty> ();
81 test_is_nothrow_constructible<Empty, const Empty&> ();
83 test_is_not_nothrow_constructible<A, int> ();
84 test_is_not_nothrow_constructible<A, int, double> ();
85 test_is_not_nothrow_constructible<A> ();
86 test_is_not_nothrow_constructible<C> ();
87 #if TEST_STD_VER >= 11
88 test_is_nothrow_constructible<Tuple &&, Empty> (); // See bug #19616.
90 static_assert(!std::is_constructible<Tuple&, Empty>::value, "");
91 test_is_not_nothrow_constructible<Tuple &, Empty> (); // See bug #19616.
92 #endif
94 return 0;