• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // type_traits
11 
12 // is_move_constructible
13 
14 #include <type_traits>
15 #include "test_macros.h"
16 
17 template <class T>
test_is_move_constructible()18 void test_is_move_constructible()
19 {
20     static_assert( std::is_move_constructible<T>::value, "");
21 #if TEST_STD_VER > 14
22     static_assert( std::is_move_constructible_v<T>, "");
23 #endif
24 }
25 
26 template <class T>
test_is_not_move_constructible()27 void test_is_not_move_constructible()
28 {
29     static_assert(!std::is_move_constructible<T>::value, "");
30 #if TEST_STD_VER > 14
31     static_assert(!std::is_move_constructible_v<T>, "");
32 #endif
33 }
34 
35 class Empty
36 {
37 };
38 
39 class NotEmpty
40 {
41 public:
42     virtual ~NotEmpty();
43 };
44 
45 union Union {};
46 
47 struct bit_zero
48 {
49     int :  0;
50 };
51 
52 class Abstract
53 {
54 public:
55     virtual ~Abstract() = 0;
56 };
57 
58 struct A
59 {
60     A(const A&);
61 };
62 
63 struct B
64 {
65 #if TEST_STD_VER >= 11
66     B(B&&);
67 #endif
68 };
69 
main()70 int main()
71 {
72     test_is_not_move_constructible<char[3]>();
73     test_is_not_move_constructible<char[]>();
74     test_is_not_move_constructible<void>();
75     test_is_not_move_constructible<Abstract>();
76 
77     test_is_move_constructible<A>();
78     test_is_move_constructible<int&>();
79     test_is_move_constructible<Union>();
80     test_is_move_constructible<Empty>();
81     test_is_move_constructible<int>();
82     test_is_move_constructible<double>();
83     test_is_move_constructible<int*>();
84     test_is_move_constructible<const int*>();
85     test_is_move_constructible<NotEmpty>();
86     test_is_move_constructible<bit_zero>();
87     test_is_move_constructible<B>();
88 }
89