is_trivially_copy_assignable.pass.cpp revision 1468b668aa964beb1220e9b36162b092fb54952b
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_trivially_copy_assignable
13
14#include <type_traits>
15
16template <class T, bool Result>
17void test_has_trivial_assign()
18{
19    static_assert(std::is_trivially_copy_assignable<T>::value == Result, "");
20}
21
22class Empty
23{
24};
25
26class NotEmpty
27{
28    virtual ~NotEmpty();
29};
30
31union Union {};
32
33struct bit_zero
34{
35    int :  0;
36};
37
38class Abstract
39{
40    virtual ~Abstract() = 0;
41};
42
43struct A
44{
45    A& operator=(const A&);
46};
47
48int main()
49{
50    test_has_trivial_assign<void, false>();
51    test_has_trivial_assign<A, false>();
52    test_has_trivial_assign<int&, true>();
53    test_has_trivial_assign<NotEmpty, false>();
54    test_has_trivial_assign<Abstract, false>();
55    test_has_trivial_assign<const Empty, false>();
56
57    test_has_trivial_assign<Union, true>();
58    test_has_trivial_assign<Empty, true>();
59    test_has_trivial_assign<int, true>();
60    test_has_trivial_assign<double, true>();
61    test_has_trivial_assign<int*, true>();
62    test_has_trivial_assign<const int*, true>();
63    test_has_trivial_assign<bit_zero, true>();
64}
65