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 template <class T>
test_is_nothrow_move_constructible()17 void test_is_nothrow_move_constructible()
18 {
19     static_assert( std::is_nothrow_move_constructible<T>::value, "");
20     static_assert( std::is_nothrow_move_constructible<const T>::value, "");
21 #if TEST_STD_VER > 14
22     static_assert( std::is_nothrow_move_constructible_v<T>, "");
23     static_assert( std::is_nothrow_move_constructible_v<const T>, "");
24 #endif
25 }
26 
27 template <class T>
test_has_not_nothrow_move_constructor()28 void test_has_not_nothrow_move_constructor()
29 {
30     static_assert(!std::is_nothrow_move_constructible<T>::value, "");
31     static_assert(!std::is_nothrow_move_constructible<const T>::value, "");
32     static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "");
33     static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "");
34 #if TEST_STD_VER > 14
35     static_assert(!std::is_nothrow_move_constructible_v<T>, "");
36     static_assert(!std::is_nothrow_move_constructible_v<const T>, "");
37     static_assert(!std::is_nothrow_move_constructible_v<volatile T>, "");
38     static_assert(!std::is_nothrow_move_constructible_v<const volatile T>, "");
39 #endif
40 }
41 
42 class Empty
43 {
44 };
45 
46 union Union {};
47 
48 struct bit_zero
49 {
50     int :  0;
51 };
52 
53 struct A
54 {
55     A(const A&);
56 };
57 
main(int,char **)58 int main(int, char**)
59 {
60     test_has_not_nothrow_move_constructor<void>();
61     test_has_not_nothrow_move_constructor<A>();
62 
63     test_is_nothrow_move_constructible<int&>();
64     test_is_nothrow_move_constructible<Union>();
65     test_is_nothrow_move_constructible<Empty>();
66     test_is_nothrow_move_constructible<int>();
67     test_is_nothrow_move_constructible<double>();
68     test_is_nothrow_move_constructible<int*>();
69     test_is_nothrow_move_constructible<const int*>();
70     test_is_nothrow_move_constructible<bit_zero>();
71 
72   return 0;
73 }
74