]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_trivially_assignable / value.cc
CommitLineData
52066eae 1// { dg-do compile { target c++11 } }
f5e523b7
VV
2//
3// 2014-10-09 Ville Voutilainen <ville.voutilainen@gmail.com>
4//
99dee823 5// Copyright (C) 2014-2021 Free Software Foundation, Inc.
f5e523b7
VV
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 3, or (at your option)
11// any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License along
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
21
22#include <type_traits>
23#include <testsuite_tr1.h>
24
25struct HasTemplateCAssign
26{
27 HasTemplateCAssign& operator=(const HasTemplateCAssign&) = default;
28 template <class T>
29 HasTemplateCAssign& operator=(T&&);
30};
31
32struct MoveOnly
33{
34 MoveOnly& operator=(MoveOnly&&) = default;
35};
36
37struct MoveOnly2
38{
39 MoveOnly2& operator=(MoveOnly2&&) = delete;
40};
41
42void test01()
43{
44 using std::is_trivially_assignable;
45 using namespace __gnu_test;
46
c01f9216 47 static_assert(test_property<is_trivially_assignable,
f5e523b7 48 int, int>(false), "");
c01f9216 49 static_assert(test_property<is_trivially_assignable,
f5e523b7 50 int&, int>(true), "");
c01f9216 51 static_assert(test_property<is_trivially_assignable,
f5e523b7 52 int&, int&>(true), "");
c01f9216 53 static_assert(test_property<is_trivially_assignable,
f5e523b7 54 int&, int&&>(true), "");
c01f9216 55 static_assert(test_property<is_trivially_assignable,
f5e523b7 56 int&, const int&>(true), "");
c01f9216
JW
57 static_assert(test_property<is_trivially_assignable,
58 int&, int*>(false), "");
59 static_assert(test_property<is_trivially_assignable,
60 int&, void*>(false), "");
61 static_assert(test_property<is_trivially_assignable,
62 const int, int>(false), "");
63 static_assert(test_property<is_trivially_assignable,
64 const int&, int>(false), "");
65 static_assert(test_property<is_trivially_assignable,
66 const int&, const int&>(false), "");
67 static_assert(test_property<is_trivially_assignable,
68 const int*&, int*>(true), "");
69 static_assert(test_property<is_trivially_assignable,
70 int*&, const int*&>(false), "");
71 static_assert(test_property<is_trivially_assignable,
72 int*&, const int&>(false), "");
73 static_assert(test_property<is_trivially_assignable,
74 const int*&, void*>(false), "");
75 static_assert(test_property<is_trivially_assignable,
76 const void*&, void*>(true), "");
77 static_assert(test_property<is_trivially_assignable,
78 const void*&, int*>(true), "");
f5e523b7 79
c01f9216 80 static_assert(test_property<is_trivially_assignable,
f5e523b7 81 TType, TType>(true), "");
c01f9216 82 static_assert(test_property<is_trivially_assignable,
f5e523b7 83 TType&, TType>(true), "");
c01f9216 84 static_assert(test_property<is_trivially_assignable,
f5e523b7 85 TType&, TType&>(true), "");
c01f9216 86 static_assert(test_property<is_trivially_assignable,
f5e523b7 87 TType&, TType&&>(true), "");
c01f9216 88 static_assert(test_property<is_trivially_assignable,
f5e523b7 89 TType&, const TType&>(true), "");
c01f9216 90 static_assert(test_property<is_trivially_assignable,
f5e523b7 91 PODType, PODType>(true), "");
c01f9216 92 static_assert(test_property<is_trivially_assignable,
f5e523b7 93 NType&, NType&>(false), "");
c01f9216 94 static_assert(test_property<is_trivially_assignable,
f5e523b7 95 SLType, SLType>(true), "");
c01f9216 96 static_assert(test_property<is_trivially_assignable,
f5e523b7 97 assign::Empty, assign::Empty>(true), "");
c01f9216 98 static_assert(test_property<is_trivially_assignable,
f5e523b7 99 assign::Abstract, assign::Abstract>(false), "");
c01f9216 100 static_assert(test_property<is_trivially_assignable,
f5e523b7 101 assign::Ellipsis, assign::Ellipsis>(true), "");
c01f9216 102 static_assert(test_property<is_trivially_assignable,
f5e523b7 103 assign::DelEllipsis, assign::DelEllipsis>(true), "");
c01f9216 104 static_assert(test_property<is_trivially_assignable,
f5e523b7 105 assign::Any, assign::Any>(true), "");
c01f9216 106 static_assert(test_property<is_trivially_assignable,
f5e523b7 107 assign::DelDef, assign::DelDef>(true), "");
c01f9216 108 static_assert(test_property<is_trivially_assignable,
f5e523b7 109 assign::DelCopy, assign::DelCopy>(true), "");
c01f9216 110 static_assert(test_property<is_trivially_assignable,
f5e523b7 111 assign::Nontrivial, assign::Nontrivial>(false), "");
c01f9216 112 static_assert(test_property<is_trivially_assignable,
f5e523b7 113 assign::AnyAssign, assign::AnyAssign>(true), "");
c01f9216 114 static_assert(test_property<is_trivially_assignable,
f5e523b7 115 assign::DelAnyAssign, assign::DelAnyAssign>(true), "");
c01f9216 116 static_assert(test_property<is_trivially_assignable,
f5e523b7 117 assign::DelCopyAssign, assign::DelCopyAssign>(true), "");
c01f9216 118 static_assert(test_property<is_trivially_assignable,
f5e523b7 119 assign::MO, assign::MO>(true), "");
c01f9216 120 static_assert(test_property<is_trivially_assignable,
f5e523b7 121 assign::MO, assign::MO&&>(true), "");
c01f9216 122 static_assert(test_property<is_trivially_assignable,
f5e523b7 123 assign::MO, assign::MO&>(false), "");
c01f9216 124 static_assert(test_property<is_trivially_assignable,
f5e523b7 125 assign::MO, const assign::MO&>(false), "");
c01f9216 126 static_assert(test_property<is_trivially_assignable,
f5e523b7 127 CopyConsOnlyType, CopyConsOnlyType>(false), "");
c01f9216 128 static_assert(test_property<is_trivially_assignable,
f5e523b7 129 CopyConsOnlyType, const CopyConsOnlyType&>(false), "");
c01f9216 130 static_assert(test_property<is_trivially_assignable,
f5e523b7 131 MoveConsOnlyType, MoveConsOnlyType>(false), "");
c01f9216 132 static_assert(test_property<is_trivially_assignable,
f5e523b7 133 MoveConsOnlyType, MoveConsOnlyType&&>(false), "");
c01f9216 134 static_assert(test_property<is_trivially_assignable,
f5e523b7 135 HasTemplateCAssign, HasTemplateCAssign>(false), "");
c01f9216 136 static_assert(test_property<is_trivially_assignable,
f5e523b7 137 HasTemplateCAssign, const HasTemplateCAssign&>(true), "");
c01f9216 138 static_assert(test_property<is_trivially_assignable,
f5e523b7 139 ClassType, DerivedType>(true), "");
c01f9216 140 static_assert(test_property<is_trivially_assignable,
f5e523b7 141 ClassType, DerivedType&>(true), "");
c01f9216 142 static_assert(test_property<is_trivially_assignable,
f5e523b7 143 ClassType, DerivedType&&>(true), "");
c01f9216 144 static_assert(test_property<is_trivially_assignable,
f5e523b7 145 ClassType, const DerivedType&>(true), "");
c01f9216 146 static_assert(test_property<is_trivially_assignable,
f5e523b7 147 MoveOnly, MoveOnly>(true), "");
c01f9216 148 static_assert(test_property<is_trivially_assignable,
f5e523b7 149 MoveOnly, MoveOnly&&>(true), "");
c01f9216 150 static_assert(test_property<is_trivially_assignable,
f5e523b7 151 MoveOnly, MoveOnly&>(false), "");
c01f9216 152 static_assert(test_property<is_trivially_assignable,
f5e523b7 153 MoveOnly, const MoveOnly&>(false), "");
c01f9216 154 static_assert(test_property<is_trivially_assignable,
f5e523b7
VV
155 MoveOnly2, MoveOnly2>(false), "");
156}