blob: 6bd78ec9e7a1eb54789d7a8a7694c1793f3dd889 [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_trivially_copy_constructible
13
14#include <type_traits>
15
16template <class T>
17void test_is_trivially_copy_constructible()
18{
19 static_assert( std::is_trivially_copy_constructible<T>::value, "");
20 static_assert( std::is_trivially_copy_constructible<const T>::value, "");
Howard Hinnant1468b662010-11-19 22:17:28 +000021}
22
23template <class T>
24void test_has_not_trivial_copy_constructor()
25{
26 static_assert(!std::is_trivially_copy_constructible<T>::value, "");
27 static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
Howard Hinnant1468b662010-11-19 22:17:28 +000028}
29
30class Empty
31{
32};
33
34class NotEmpty
35{
36public:
37 virtual ~NotEmpty();
38};
39
40union Union {};
41
42struct bit_zero
43{
44 int : 0;
45};
46
47class Abstract
48{
49public:
50 virtual ~Abstract() = 0;
51};
52
53struct A
54{
55 A(const A&);
56};
57
58int main()
59{
60 test_has_not_trivial_copy_constructor<void>();
61 test_has_not_trivial_copy_constructor<A>();
62 test_has_not_trivial_copy_constructor<Abstract>();
63 test_has_not_trivial_copy_constructor<NotEmpty>();
64
65 test_is_trivially_copy_constructible<int&>();
66 test_is_trivially_copy_constructible<Union>();
67 test_is_trivially_copy_constructible<Empty>();
68 test_is_trivially_copy_constructible<int>();
69 test_is_trivially_copy_constructible<double>();
70 test_is_trivially_copy_constructible<int*>();
71 test_is_trivially_copy_constructible<const int*>();
72 test_is_trivially_copy_constructible<bit_zero>();
73}