Debian Codegraph @

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_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_trivially_move_constructible
12
13 #include <type_traits>
14 #include "test_macros.h"
15
16 template <class T>
17 void test_is_trivially_move_constructible()
18 {
19 static_assert( std::is_trivially_move_constructible<T>::value, "");
20 #if TEST_STD_VER > 14
21 static_assert( std::is_trivially_move_constructible_v<T>, "");
22 #endif
23 }
24
25 template <class T>
26 void test_has_not_trivial_move_constructor()
27 {
28 static_assert(!std::is_trivially_move_constructible<T>::value, "");
29 #if TEST_STD_VER > 14
30 static_assert(!std::is_trivially_move_constructible_v<T>, "");
31 #endif
32 }
33
34 class Empty
35 {
36 };
37
38 class NotEmpty
39 {
40 public:
41 virtual ~NotEmpty();
42 };
43
44 union Union {};
45
46 struct bit_zero
47 {
48 int : 0;
49 };
50
51 class Abstract
52 {
53 public:
54 virtual ~Abstract() = 0;
55 };
56
57 struct A
58 {
59 A(const A&);
60 };
61
62 #if TEST_STD_VER >= 11
63
64 struct MoveOnly1
65 {
66 MoveOnly1(MoveOnly1&&);
67 };
68
69 struct MoveOnly2
70 {
71 MoveOnly2(MoveOnly2&&) = default;
72 };
73
74 #endif
75
76 int main(int, char**)
77 {
78 test_has_not_trivial_move_constructor<void>();
79 test_has_not_trivial_move_constructor<A>();
80 test_has_not_trivial_move_constructor<Abstract>();
81 test_has_not_trivial_move_constructor<NotEmpty>();
82
83 test_is_trivially_move_constructible<Union>();
84 test_is_trivially_move_constructible<Empty>();
85 test_is_trivially_move_constructible<int>();
86 test_is_trivially_move_constructible<double>();
87 test_is_trivially_move_constructible<int*>();
88 test_is_trivially_move_constructible<const int*>();
89 test_is_trivially_move_constructible<bit_zero>();
90
91 #if TEST_STD_VER >= 11
92 static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, "");
93 static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, "");
94 #endif
95
96 return 0;
97 }