blob: 7409ebaa56c8fa894c3b8a774412eaa21dcb17e9 [file] [log] [blame]
Howard Hinnant1468b662010-11-19 22:17:28 +00001//===----------------------------------------------------------------------===//
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
Marshall Clow933afa92013-07-04 00:10:01 +000016template <class T>
Howard Hinnant1468b662010-11-19 22:17:28 +000017void test_is_move_constructible()
18{
Marshall Clow933afa92013-07-04 00:10:01 +000019 static_assert( std::is_move_constructible<T>::value, "");
20}
21
22template <class T>
23void test_is_not_move_constructible()
24{
25 static_assert(!std::is_move_constructible<T>::value, "");
Howard Hinnant1468b662010-11-19 22:17:28 +000026}
27
28class Empty
29{
30};
31
32class NotEmpty
33{
34public:
35 virtual ~NotEmpty();
36};
37
38union Union {};
39
40struct bit_zero
41{
42 int : 0;
43};
44
45class Abstract
46{
47public:
48 virtual ~Abstract() = 0;
49};
50
51struct A
52{
53 A(const A&);
54};
55
56struct B
57{
Marshall Clow933afa92013-07-04 00:10:01 +000058#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant1468b662010-11-19 22:17:28 +000059 B(B&&);
Marshall Clow933afa92013-07-04 00:10:01 +000060#endif
Howard Hinnant1468b662010-11-19 22:17:28 +000061};
62
63int main()
64{
Marshall Clow933afa92013-07-04 00:10:01 +000065 test_is_not_move_constructible<char[3]>();
66 test_is_not_move_constructible<char[]>();
67 test_is_not_move_constructible<void>();
68 test_is_not_move_constructible<Abstract>();
Howard Hinnant1468b662010-11-19 22:17:28 +000069
Marshall Clow933afa92013-07-04 00:10:01 +000070 test_is_move_constructible<A>();
71 test_is_move_constructible<int&>();
72 test_is_move_constructible<Union>();
73 test_is_move_constructible<Empty>();
74 test_is_move_constructible<int>();
75 test_is_move_constructible<double>();
76 test_is_move_constructible<int*>();
77 test_is_move_constructible<const int*>();
78 test_is_move_constructible<NotEmpty>();
79 test_is_move_constructible<bit_zero>();
80 test_is_move_constructible<B>();
Howard Hinnant1468b662010-11-19 22:17:28 +000081}