blob: 966573c9f0fe520f2945dcef883a96e9aac6f826 [file] [log] [blame]
Dan Albert287553d2017-02-16 10:47:51 -08001//===----------------------------------------------------------------------===//
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_assignable
13
14// XFAIL: gcc-4.9
15
16#include <type_traits>
17#include "test_macros.h"
18
19template <class T>
20void test_has_trivially_copy_assignable()
21{
22 static_assert( std::is_trivially_copy_assignable<T>::value, "");
23#if TEST_STD_VER > 14
24 static_assert( std::is_trivially_copy_assignable_v<T>, "");
25#endif
26}
27
28template <class T>
29void test_has_not_trivially_copy_assignable()
30{
31 static_assert(!std::is_trivially_copy_assignable<T>::value, "");
32#if TEST_STD_VER > 14
33 static_assert(!std::is_trivially_copy_assignable_v<T>, "");
34#endif
35}
36
37class Empty
38{
39};
40
41class NotEmpty
42{
43 virtual ~NotEmpty();
44};
45
46union Union {};
47
48struct bit_zero
49{
50 int : 0;
51};
52
53class Abstract
54{
55 virtual ~Abstract() = 0;
56};
57
58struct A
59{
60 A& operator=(const A&);
61};
62
63int main()
64{
65 test_has_trivially_copy_assignable<int&>();
66 test_has_trivially_copy_assignable<Union>();
67 test_has_trivially_copy_assignable<Empty>();
68 test_has_trivially_copy_assignable<int>();
69 test_has_trivially_copy_assignable<double>();
70 test_has_trivially_copy_assignable<int*>();
71 test_has_trivially_copy_assignable<const int*>();
72 test_has_trivially_copy_assignable<bit_zero>();
73
74 test_has_not_trivially_copy_assignable<void>();
75 test_has_not_trivially_copy_assignable<A>();
76 test_has_not_trivially_copy_assignable<NotEmpty>();
77 test_has_not_trivially_copy_assignable<Abstract>();
78 test_has_not_trivially_copy_assignable<const Empty>();
79
80}