]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/is_trivially_constructible/value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_trivially_constructible / 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//
83ffe9cd 5// Copyright (C) 2014-2023 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 HasTemplateCCtor
26{
27 HasTemplateCCtor(const HasTemplateCCtor&) = default;
28 template <class T>
29 HasTemplateCCtor(T&&);
30};
31
32struct MoveOnly
33{
34 MoveOnly(MoveOnly&&) = default;
35};
36
37struct MoveOnly2
38{
39 MoveOnly2(MoveOnly2&&) = delete;
40};
41
42void test01()
43{
44 using std::is_trivially_constructible;
45 using namespace __gnu_test;
46
e9029d55 47 static_assert(test_property<is_trivially_constructible,
f5e523b7 48 int>(true), "");
e9029d55 49 static_assert(test_property<is_trivially_constructible,
f5e523b7 50 int, int>(true), "");
e9029d55 51 static_assert(test_property<is_trivially_constructible,
f5e523b7 52 int, int&>(true), "");
e9029d55 53 static_assert(test_property<is_trivially_constructible,
f5e523b7 54 int, int&&>(true), "");
e9029d55 55 static_assert(test_property<is_trivially_constructible,
f5e523b7 56 int, const int&>(true), "");
e9029d55
JW
57 static_assert(test_property<is_trivially_constructible,
58 int, void*>(false), "PR 86398");
59 static_assert(test_property<is_trivially_constructible,
60 int, int*>(false), "PR 86398");
61 static_assert(test_property<is_trivially_constructible,
62 int, const int*>(false), "PR 86398");
63 static_assert(test_property<is_trivially_constructible,
64 int*, void*>(false), "PR 86398");
65 static_assert(test_property<is_trivially_constructible,
66 int*, const int*>(false), "PR 86398");
67 static_assert(test_property<is_trivially_constructible,
68 int&, const int>(false), "");
69 static_assert(test_property<is_trivially_constructible,
70 const int&, int>(true), "");
71 static_assert(test_property<is_trivially_constructible,
72 const int&, int&>(true), "");
73 static_assert(test_property<is_trivially_constructible,
74 const int*, int*>(true), "");
75 static_assert(test_property<is_trivially_constructible,
f5e523b7 76 PolymorphicClass>(false), "");
e9029d55 77 static_assert(test_property<is_trivially_constructible,
f5e523b7 78 PolymorphicClass, PolymorphicClass>(false), "");
e9029d55 79 static_assert(test_property<is_trivially_constructible,
f5e523b7 80 PolymorphicClass, PolymorphicClass&>(false), "");
e9029d55 81 static_assert(test_property<is_trivially_constructible,
f5e523b7 82 PolymorphicClass, PolymorphicClass&&>(false), "");
e9029d55 83 static_assert(test_property<is_trivially_constructible,
f5e523b7 84 PolymorphicClass, const PolymorphicClass&>(false), "");
e9029d55 85 static_assert(test_property<is_trivially_constructible,
f5e523b7 86 TType>(true), "");
e9029d55 87 static_assert(test_property<is_trivially_constructible,
f5e523b7 88 TType, TType>(true), "");
e9029d55 89 static_assert(test_property<is_trivially_constructible,
f5e523b7 90 TType, TType&>(true), "");
e9029d55 91 static_assert(test_property<is_trivially_constructible,
f5e523b7 92 TType, TType&&>(true), "");
e9029d55 93 static_assert(test_property<is_trivially_constructible,
f5e523b7 94 TType, const TType&>(true), "");
e9029d55 95 static_assert(test_property<is_trivially_constructible,
f5e523b7 96 TType, int, int>(false), "");
e9029d55 97 static_assert(test_property<is_trivially_constructible,
f5e523b7 98 PODType>(true), "");
e9029d55 99 static_assert(test_property<is_trivially_constructible,
f5e523b7 100 PODType, PODType>(true), "");
e9029d55 101 static_assert(test_property<is_trivially_constructible,
f5e523b7 102 PODType, PODType&>(true), "");
e9029d55 103 static_assert(test_property<is_trivially_constructible,
f5e523b7 104 PODType, PODType&&>(true), "");
e9029d55 105 static_assert(test_property<is_trivially_constructible,
f5e523b7 106 PODType, const PODType&>(true), "");
e9029d55 107 static_assert(test_property<is_trivially_constructible,
7646847d 108 PODType, int, int>(__cplusplus >= 202002L), "");
e9029d55 109 static_assert(test_property<is_trivially_constructible,
f5e523b7 110 NType>(false), "");
e9029d55 111 static_assert(test_property<is_trivially_constructible,
f5e523b7 112 SLType>(false), "");
e9029d55 113 static_assert(test_property<is_trivially_constructible,
f5e523b7 114 LType>(false), "");
e9029d55 115 static_assert(test_property<is_trivially_constructible,
f5e523b7 116 LType, int>(false), "");
e9029d55 117 static_assert(test_property<is_trivially_constructible,
f5e523b7 118 construct::DelDef>(false), "");
e9029d55 119 static_assert(test_property<is_trivially_constructible,
f5e523b7 120 construct::Abstract>(false), "");
e9029d55 121 static_assert(test_property<is_trivially_constructible,
f5e523b7 122 construct::Ellipsis>(false), "");
e9029d55 123 static_assert(test_property<is_trivially_constructible,
f5e523b7 124 construct::DelEllipsis>(false), "");
e9029d55 125 static_assert(test_property<is_trivially_constructible,
f5e523b7 126 construct::Any>(false), "");
e9029d55 127 static_assert(test_property<is_trivially_constructible,
f5e523b7 128 construct::DelCopy>(false), "");
e9029d55 129 static_assert(test_property<is_trivially_constructible,
f5e523b7 130 construct::DelCopy, const construct::DelCopy&>(false), "");
e9029d55 131 static_assert(test_property<is_trivially_constructible,
f5e523b7 132 construct::DelDtor>(false), "");
e9029d55 133 static_assert(test_property<is_trivially_constructible,
f5e523b7 134 construct::Nontrivial>(false), "");
e9029d55 135 static_assert(test_property<is_trivially_constructible,
f5e523b7 136 construct::UnusualCopy>(false), "");
e9029d55 137 static_assert(test_property<is_trivially_constructible,
f5e523b7 138 CopyConsOnlyType>(false), "");
e9029d55 139 static_assert(test_property<is_trivially_constructible,
f5e523b7 140 CopyConsOnlyType, CopyConsOnlyType>(false), "");
e9029d55 141 static_assert(test_property<is_trivially_constructible,
f5e523b7 142 CopyConsOnlyType, CopyConsOnlyType&>(true), "");
e9029d55 143 static_assert(test_property<is_trivially_constructible,
f5e523b7 144 CopyConsOnlyType, CopyConsOnlyType&&>(false), "");
e9029d55 145 static_assert(test_property<is_trivially_constructible,
f5e523b7 146 CopyConsOnlyType, const CopyConsOnlyType&>(true), "");
e9029d55 147 static_assert(test_property<is_trivially_constructible,
f5e523b7 148 MoveConsOnlyType>(false), "");
e9029d55 149 static_assert(test_property<is_trivially_constructible,
f5e523b7 150 MoveConsOnlyType, MoveConsOnlyType>(true), "");
e9029d55 151 static_assert(test_property<is_trivially_constructible,
f5e523b7 152 MoveConsOnlyType, MoveConsOnlyType&>(false), "");
e9029d55 153 static_assert(test_property<is_trivially_constructible,
f5e523b7 154 MoveConsOnlyType, MoveConsOnlyType&&>(true), "");
e9029d55 155 static_assert(test_property<is_trivially_constructible,
f5e523b7 156 MoveConsOnlyType, const MoveConsOnlyType&>(false), "");
e9029d55 157 static_assert(test_property<is_trivially_constructible,
f5e523b7 158 ClassType, DerivedType>(true), "");
e9029d55 159 static_assert(test_property<is_trivially_constructible,
f5e523b7 160 ClassType, DerivedType&>(true), "");
e9029d55 161 static_assert(test_property<is_trivially_constructible,
f5e523b7 162 ClassType, DerivedType&&>(true), "");
e9029d55 163 static_assert(test_property<is_trivially_constructible,
f5e523b7 164 ClassType, const DerivedType&>(true), "");
e9029d55 165 static_assert(test_property<is_trivially_constructible,
f5e523b7 166 HasTemplateCCtor>(false), "");
e9029d55 167 static_assert(test_property<is_trivially_constructible,
f5e523b7 168 HasTemplateCCtor, HasTemplateCCtor>(false), "");
e9029d55 169 static_assert(test_property<is_trivially_constructible,
f5e523b7 170 HasTemplateCCtor, const HasTemplateCCtor&>(true), "");
e9029d55 171 static_assert(test_property<is_trivially_constructible,
f5e523b7 172 MoveOnly>(false), "");
e9029d55 173 static_assert(test_property<is_trivially_constructible,
f5e523b7 174 MoveOnly, MoveOnly>(true), "");
e9029d55 175 static_assert(test_property<is_trivially_constructible,
f5e523b7 176 MoveOnly, MoveOnly&>(false), "");
e9029d55 177 static_assert(test_property<is_trivially_constructible,
f5e523b7 178 MoveOnly, MoveOnly&&>(true), "");
e9029d55 179 static_assert(test_property<is_trivially_constructible,
f5e523b7 180 MoveOnly, const MoveOnly&>(false), "");
e9029d55 181 static_assert(test_property<is_trivially_constructible,
f5e523b7 182 MoveOnly2>(false), "");
58487c21
JW
183 static_assert(test_property<is_trivially_constructible,
184 int[]>(false), "PR c++/90532");
f5e523b7 185}