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 | // has_nothrow_move_constructor |
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_move_constructible() |
20 | { |
21 | static_assert( std::is_nothrow_move_constructible<T>::value, "" ); |
22 | static_assert( std::is_nothrow_move_constructible<const T>::value, "" ); |
23 | #if TEST_STD_VER > 14 |
24 | static_assert( std::is_nothrow_move_constructible_v<T>, "" ); |
25 | static_assert( std::is_nothrow_move_constructible_v<const T>, "" ); |
26 | #endif |
27 | } |
28 | |
29 | template <class T> |
30 | void test_has_not_nothrow_move_constructor() |
31 | { |
32 | static_assert(!std::is_nothrow_move_constructible<T>::value, "" ); |
33 | static_assert(!std::is_nothrow_move_constructible<const T>::value, "" ); |
34 | static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "" ); |
35 | static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "" ); |
36 | #if TEST_STD_VER > 14 |
37 | static_assert(!std::is_nothrow_move_constructible_v<T>, "" ); |
38 | static_assert(!std::is_nothrow_move_constructible_v<const T>, "" ); |
39 | static_assert(!std::is_nothrow_move_constructible_v<volatile T>, "" ); |
40 | static_assert(!std::is_nothrow_move_constructible_v<const volatile T>, "" ); |
41 | #endif |
42 | } |
43 | |
44 | int main(int, char**) |
45 | { |
46 | test_has_not_nothrow_move_constructor<void>(); |
47 | test_has_not_nothrow_move_constructor<A>(); |
48 | // TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved |
49 | #if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC) |
50 | test_has_not_nothrow_move_constructor<TrivialNotNoexcept>(); |
51 | #endif |
52 | |
53 | test_is_nothrow_move_constructible<int&>(); |
54 | test_is_nothrow_move_constructible<Union>(); |
55 | test_is_nothrow_move_constructible<Empty>(); |
56 | test_is_nothrow_move_constructible<int>(); |
57 | test_is_nothrow_move_constructible<double>(); |
58 | test_is_nothrow_move_constructible<int*>(); |
59 | test_is_nothrow_move_constructible<const int*>(); |
60 | test_is_nothrow_move_constructible<bit_zero>(); |
61 | |
62 | return 0; |
63 | } |
64 | |