| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// |
| 3 |
// 2014-10-09 Ville Voutilainen <[email protected]> |
| 4 |
// |
| 5 |
// Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 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 |
|
| 25 |
struct HasTemplateCCtor |
| 26 |
{ |
| 27 |
HasTemplateCCtor(const HasTemplateCCtor&) = default; |
| 28 |
template <class T> |
| 29 |
HasTemplateCCtor(T&&); |
| 30 |
}; |
| 31 |
|
| 32 |
struct MoveOnly |
| 33 |
{ |
| 34 |
MoveOnly(MoveOnly&&) = default; |
| 35 |
}; |
| 36 |
|
| 37 |
struct MoveOnly2 |
| 38 |
{ |
| 39 |
MoveOnly2(MoveOnly2&&) = delete; |
| 40 |
}; |
| 41 |
|
| 42 |
void test01() |
| 43 |
{ |
| 44 |
using std::is_trivially_constructible; |
| 45 |
using namespace __gnu_test; |
| 46 |
|
| 47 |
static_assert(test_property<is_trivially_constructible, |
| 48 |
int>(true), ""); |
| 49 |
static_assert(test_property<is_trivially_constructible, |
| 50 |
int, int>(true), ""); |
| 51 |
static_assert(test_property<is_trivially_constructible, |
| 52 |
int, int&>(true), ""); |
| 53 |
static_assert(test_property<is_trivially_constructible, |
| 54 |
int, int&&>(true), ""); |
| 55 |
static_assert(test_property<is_trivially_constructible, |
| 56 |
int, const int&>(true), ""); |
| 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, |
| 76 |
PolymorphicClass>(false), ""); |
| 77 |
static_assert(test_property<is_trivially_constructible, |
| 78 |
PolymorphicClass, PolymorphicClass>(false), ""); |
| 79 |
static_assert(test_property<is_trivially_constructible, |
| 80 |
PolymorphicClass, PolymorphicClass&>(false), ""); |
| 81 |
static_assert(test_property<is_trivially_constructible, |
| 82 |
PolymorphicClass, PolymorphicClass&&>(false), ""); |
| 83 |
static_assert(test_property<is_trivially_constructible, |
| 84 |
PolymorphicClass, const PolymorphicClass&>(false), ""); |
| 85 |
static_assert(test_property<is_trivially_constructible, |
| 86 |
TType>(true), ""); |
| 87 |
static_assert(test_property<is_trivially_constructible, |
| 88 |
TType, TType>(true), ""); |
| 89 |
static_assert(test_property<is_trivially_constructible, |
| 90 |
TType, TType&>(true), ""); |
| 91 |
static_assert(test_property<is_trivially_constructible, |
| 92 |
TType, TType&&>(true), ""); |
| 93 |
static_assert(test_property<is_trivially_constructible, |
| 94 |
TType, const TType&>(true), ""); |
| 95 |
static_assert(test_property<is_trivially_constructible, |
| 96 |
TType, int, int>(false), ""); |
| 97 |
static_assert(test_property<is_trivially_constructible, |
| 98 |
PODType>(true), ""); |
| 99 |
static_assert(test_property<is_trivially_constructible, |
| 100 |
PODType, PODType>(true), ""); |
| 101 |
static_assert(test_property<is_trivially_constructible, |
| 102 |
PODType, PODType&>(true), ""); |
| 103 |
static_assert(test_property<is_trivially_constructible, |
| 104 |
PODType, PODType&&>(true), ""); |
| 105 |
static_assert(test_property<is_trivially_constructible, |
| 106 |
PODType, const PODType&>(true), ""); |
| 107 |
static_assert(test_property<is_trivially_constructible, |
| 108 |
PODType, int, int>(__cplusplus >= 202002L), ""); |
| 109 |
static_assert(test_property<is_trivially_constructible, |
| 110 |
NType>(false), ""); |
| 111 |
static_assert(test_property<is_trivially_constructible, |
| 112 |
SLType>(false), ""); |
| 113 |
static_assert(test_property<is_trivially_constructible, |
| 114 |
LType>(false), ""); |
| 115 |
static_assert(test_property<is_trivially_constructible, |
| 116 |
LType, int>(false), ""); |
| 117 |
static_assert(test_property<is_trivially_constructible, |
| 118 |
construct::DelDef>(false), ""); |
| 119 |
static_assert(test_property<is_trivially_constructible, |
| 120 |
construct::Abstract>(false), ""); |
| 121 |
static_assert(test_property<is_trivially_constructible, |
| 122 |
construct::Ellipsis>(false), ""); |
| 123 |
static_assert(test_property<is_trivially_constructible, |
| 124 |
construct::DelEllipsis>(false), ""); |
| 125 |
static_assert(test_property<is_trivially_constructible, |
| 126 |
construct::Any>(false), ""); |
| 127 |
static_assert(test_property<is_trivially_constructible, |
| 128 |
construct::DelCopy>(false), ""); |
| 129 |
static_assert(test_property<is_trivially_constructible, |
| 130 |
construct::DelCopy, const construct::DelCopy&>(false), ""); |
| 131 |
static_assert(test_property<is_trivially_constructible, |
| 132 |
construct::DelDtor>(false), ""); |
| 133 |
static_assert(test_property<is_trivially_constructible, |
| 134 |
construct::Nontrivial>(false), ""); |
| 135 |
static_assert(test_property<is_trivially_constructible, |
| 136 |
construct::UnusualCopy>(false), ""); |
| 137 |
static_assert(test_property<is_trivially_constructible, |
| 138 |
CopyConsOnlyType>(false), ""); |
| 139 |
static_assert(test_property<is_trivially_constructible, |
| 140 |
CopyConsOnlyType, CopyConsOnlyType>(false), ""); |
| 141 |
static_assert(test_property<is_trivially_constructible, |
| 142 |
CopyConsOnlyType, CopyConsOnlyType&>(true), ""); |
| 143 |
static_assert(test_property<is_trivially_constructible, |
| 144 |
CopyConsOnlyType, CopyConsOnlyType&&>(false), ""); |
| 145 |
static_assert(test_property<is_trivially_constructible, |
| 146 |
CopyConsOnlyType, const CopyConsOnlyType&>(true), ""); |
| 147 |
static_assert(test_property<is_trivially_constructible, |
| 148 |
MoveConsOnlyType>(false), ""); |
| 149 |
static_assert(test_property<is_trivially_constructible, |
| 150 |
MoveConsOnlyType, MoveConsOnlyType>(true), ""); |
| 151 |
static_assert(test_property<is_trivially_constructible, |
| 152 |
MoveConsOnlyType, MoveConsOnlyType&>(false), ""); |
| 153 |
static_assert(test_property<is_trivially_constructible, |
| 154 |
MoveConsOnlyType, MoveConsOnlyType&&>(true), ""); |
| 155 |
static_assert(test_property<is_trivially_constructible, |
| 156 |
MoveConsOnlyType, const MoveConsOnlyType&>(false), ""); |
| 157 |
static_assert(test_property<is_trivially_constructible, |
| 158 |
ClassType, DerivedType>(true), ""); |
| 159 |
static_assert(test_property<is_trivially_constructible, |
| 160 |
ClassType, DerivedType&>(true), ""); |
| 161 |
static_assert(test_property<is_trivially_constructible, |
| 162 |
ClassType, DerivedType&&>(true), ""); |
| 163 |
static_assert(test_property<is_trivially_constructible, |
| 164 |
ClassType, const DerivedType&>(true), ""); |
| 165 |
static_assert(test_property<is_trivially_constructible, |
| 166 |
HasTemplateCCtor>(false), ""); |
| 167 |
static_assert(test_property<is_trivially_constructible, |
| 168 |
HasTemplateCCtor, HasTemplateCCtor>(false), ""); |
| 169 |
static_assert(test_property<is_trivially_constructible, |
| 170 |
HasTemplateCCtor, const HasTemplateCCtor&>(true), ""); |
| 171 |
static_assert(test_property<is_trivially_constructible, |
| 172 |
MoveOnly>(false), ""); |
| 173 |
static_assert(test_property<is_trivially_constructible, |
| 174 |
MoveOnly, MoveOnly>(true), ""); |
| 175 |
static_assert(test_property<is_trivially_constructible, |
| 176 |
MoveOnly, MoveOnly&>(false), ""); |
| 177 |
static_assert(test_property<is_trivially_constructible, |
| 178 |
MoveOnly, MoveOnly&&>(true), ""); |
| 179 |
static_assert(test_property<is_trivially_constructible, |
| 180 |
MoveOnly, const MoveOnly&>(false), ""); |
| 181 |
static_assert(test_property<is_trivially_constructible, |
| 182 |
MoveOnly2>(false), ""); |
| 183 |
static_assert(test_property<is_trivially_constructible, |
| 184 |
int[]>(false), "PR c++/90532"); |
| 185 |
} |