blob: f5a42afe0d50fe58444e382db83cf03c2afe5006 [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// has_nothrow_move_constructor
13
14#include <type_traits>
15
16template <class T>
17void 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, "");
Howard Hinnant1468b662010-11-19 22:17:28 +000021}
22
23template <class T>
24void test_has_not_nothrow_move_constructor()
25{
26 static_assert(!std::is_nothrow_move_constructible<T>::value, "");
27 static_assert(!std::is_nothrow_move_constructible<const T>::value, "");
28 static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "");
29 static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "");
30}
31
32class Empty
33{
34};
35
Howard Hinnant1468b662010-11-19 22:17:28 +000036union Union {};
37
38struct bit_zero
39{
40 int : 0;
41};
42
43struct A
44{
45 A(const A&);
46};
47
48int main()
49{
50 test_has_not_nothrow_move_constructor<void>();
51 test_has_not_nothrow_move_constructor<A>();
52
Howard Hinnant6063ec12011-05-13 14:08:16 +000053 test_is_nothrow_move_constructible<int&>();
Howard Hinnant1468b662010-11-19 22:17:28 +000054 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*>();
Howard Hinnant1468b662010-11-19 22:17:28 +000060 test_is_nothrow_move_constructible<bit_zero>();
61}