Debian Codegraph @

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp

raw
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 //===----------------------------------------------------------------------===//
8
9 // type_traits
10
11 // is_nothrow_copy_constructible
12
13 #include <type_traits>
14 #include "test_macros.h"
15
16 #include "common.h"
17
18 template <class T>
19 void test_is_nothrow_copy_constructible()
20 {
21 static_assert( std::is_nothrow_copy_constructible<T>::value, "");
22 static_assert( std::is_nothrow_copy_constructible<const T>::value, "");
23 #if TEST_STD_VER > 14
24 static_assert( std::is_nothrow_copy_constructible_v<T>, "");
25 static_assert( std::is_nothrow_copy_constructible_v<const T>, "");
26 #endif
27 }
28
29 template <class T>
30 void test_has_not_nothrow_copy_constructor()
31 {
32 static_assert(!std::is_nothrow_copy_constructible<T>::value, "");
33 static_assert(!std::is_nothrow_copy_constructible<const T>::value, "");
34 static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, "");
35 static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, "");
36 #if TEST_STD_VER > 14
37 static_assert(!std::is_nothrow_copy_constructible_v<T>, "");
38 static_assert(!std::is_nothrow_copy_constructible_v<const T>, "");
39 static_assert(!std::is_nothrow_copy_constructible_v<volatile T>, "");
40 static_assert(!std::is_nothrow_copy_constructible_v<const volatile T>, "");
41 #endif
42 }
43
44 int main(int, char**)
45 {
46 test_has_not_nothrow_copy_constructor<void>();
47 test_has_not_nothrow_copy_constructor<A>();
48 #if TEST_STD_VER >= 11
49 test_has_not_nothrow_copy_constructor<TrivialNotNoexcept>();
50 #endif
51
52 test_is_nothrow_copy_constructible<int&>();
53 test_is_nothrow_copy_constructible<Union>();
54 test_is_nothrow_copy_constructible<Empty>();
55 test_is_nothrow_copy_constructible<int>();
56 test_is_nothrow_copy_constructible<double>();
57 test_is_nothrow_copy_constructible<int*>();
58 test_is_nothrow_copy_constructible<const int*>();
59 test_is_nothrow_copy_constructible<bit_zero>();
60
61 return 0;
62 }