| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -DSTD1 %s |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -DSTD2 %s |
| 3 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -DSTD3 %s |
| 4 |
|
| 5 |
namespace std { |
| 6 |
|
| 7 |
#ifdef STD1 |
| 8 |
template <typename T> |
| 9 |
struct is_trivially_relocatable { |
| 10 |
static constexpr bool value = __builtin_is_cpp_trivially_relocatable(T); |
| 11 |
}; |
| 12 |
|
| 13 |
template <typename T> |
| 14 |
constexpr bool is_trivially_relocatable_v = __builtin_is_cpp_trivially_relocatable(T); |
| 15 |
|
| 16 |
template <typename T> |
| 17 |
struct is_trivially_copyable { |
| 18 |
static constexpr bool value = __is_trivially_copyable(T); |
| 19 |
}; |
| 20 |
|
| 21 |
template <typename T> |
| 22 |
constexpr bool is_trivially_copyable_v = __is_trivially_copyable(T); |
| 23 |
|
| 24 |
template <typename T, typename U> |
| 25 |
struct is_assignable { |
| 26 |
static constexpr bool value = __is_assignable(T, U); |
| 27 |
}; |
| 28 |
|
| 29 |
template <typename T, typename U> |
| 30 |
constexpr bool is_assignable_v = __is_assignable(T, U); |
| 31 |
|
| 32 |
template <typename T> |
| 33 |
struct is_empty { |
| 34 |
static constexpr bool value = __is_empty(T); |
| 35 |
}; |
| 36 |
template <typename T> |
| 37 |
constexpr bool is_empty_v = __is_empty(T); |
| 38 |
|
| 39 |
template <typename T> |
| 40 |
struct is_standard_layout { |
| 41 |
static constexpr bool value = __is_standard_layout(T); |
| 42 |
}; |
| 43 |
template <typename T> |
| 44 |
constexpr bool is_standard_layout_v = __is_standard_layout(T); |
| 45 |
|
| 46 |
template <typename... Args> |
| 47 |
struct is_constructible { |
| 48 |
static constexpr bool value = __is_constructible(Args...); |
| 49 |
}; |
| 50 |
|
| 51 |
template <typename... Args> |
| 52 |
constexpr bool is_constructible_v = __is_constructible(Args...); |
| 53 |
|
| 54 |
template <typename T> |
| 55 |
struct is_aggregate { |
| 56 |
static constexpr bool value = __is_aggregate(T); |
| 57 |
}; |
| 58 |
|
| 59 |
template <typename T> |
| 60 |
constexpr bool is_aggregate_v = __is_aggregate(T); |
| 61 |
|
| 62 |
template <typename T> |
| 63 |
struct is_final { |
| 64 |
static constexpr bool value = __is_final(T); |
| 65 |
}; |
| 66 |
template <typename T> |
| 67 |
constexpr bool is_final_v = __is_final(T); |
| 68 |
|
| 69 |
template <typename T> |
| 70 |
struct is_abstract { |
| 71 |
static constexpr bool value = __is_abstract(T); |
| 72 |
}; |
| 73 |
template <typename T> |
| 74 |
constexpr bool is_abstract_v = __is_abstract(T); |
| 75 |
|
| 76 |
#endif |
| 77 |
|
| 78 |
#ifdef STD2 |
| 79 |
template <typename T> |
| 80 |
struct __details_is_trivially_relocatable { |
| 81 |
static constexpr bool value = __builtin_is_cpp_trivially_relocatable(T); |
| 82 |
}; |
| 83 |
|
| 84 |
template <typename T> |
| 85 |
using is_trivially_relocatable = __details_is_trivially_relocatable<T>; |
| 86 |
|
| 87 |
template <typename T> |
| 88 |
constexpr bool is_trivially_relocatable_v = __builtin_is_cpp_trivially_relocatable(T); |
| 89 |
|
| 90 |
template <typename T> |
| 91 |
struct __details_is_trivially_copyable { |
| 92 |
static constexpr bool value = __is_trivially_copyable(T); |
| 93 |
}; |
| 94 |
|
| 95 |
template <typename T> |
| 96 |
using is_trivially_copyable = __details_is_trivially_copyable<T>; |
| 97 |
|
| 98 |
template <typename T> |
| 99 |
constexpr bool is_trivially_copyable_v = __is_trivially_copyable(T); |
| 100 |
|
| 101 |
template <typename T, typename U> |
| 102 |
struct __details_is_assignable { |
| 103 |
static constexpr bool value = __is_assignable(T, U); |
| 104 |
}; |
| 105 |
|
| 106 |
template <typename T, typename U> |
| 107 |
using is_assignable = __details_is_assignable<T, U>; |
| 108 |
|
| 109 |
template <typename T, typename U> |
| 110 |
constexpr bool is_assignable_v = __is_assignable(T, U); |
| 111 |
|
| 112 |
template <typename T> |
| 113 |
struct __details_is_empty { |
| 114 |
static constexpr bool value = __is_empty(T); |
| 115 |
}; |
| 116 |
template <typename T> |
| 117 |
using is_empty = __details_is_empty<T>; |
| 118 |
template <typename T> |
| 119 |
constexpr bool is_empty_v = __is_empty(T); |
| 120 |
|
| 121 |
template <typename T> |
| 122 |
struct __details_is_standard_layout { |
| 123 |
static constexpr bool value = __is_standard_layout(T); |
| 124 |
}; |
| 125 |
template <typename T> |
| 126 |
using is_standard_layout = __details_is_standard_layout<T>; |
| 127 |
template <typename T> |
| 128 |
constexpr bool is_standard_layout_v = __is_standard_layout(T); |
| 129 |
|
| 130 |
template <typename... Args> |
| 131 |
struct __details_is_constructible{ |
| 132 |
static constexpr bool value = __is_constructible(Args...); |
| 133 |
}; |
| 134 |
|
| 135 |
template <typename... Args> |
| 136 |
using is_constructible = __details_is_constructible<Args...>; |
| 137 |
|
| 138 |
template <typename... Args> |
| 139 |
constexpr bool is_constructible_v = __is_constructible(Args...); |
| 140 |
|
| 141 |
template <typename T> |
| 142 |
struct __details_is_aggregate { |
| 143 |
static constexpr bool value = __is_aggregate(T); |
| 144 |
}; |
| 145 |
|
| 146 |
template <typename T> |
| 147 |
using is_aggregate = __details_is_aggregate<T>; |
| 148 |
|
| 149 |
template <typename T> |
| 150 |
constexpr bool is_aggregate_v = __is_aggregate(T); |
| 151 |
|
| 152 |
template <typename T> |
| 153 |
struct __details_is_final { |
| 154 |
static constexpr bool value = __is_final(T); |
| 155 |
}; |
| 156 |
template <typename T> |
| 157 |
using is_final = __details_is_final<T>; |
| 158 |
template <typename T> |
| 159 |
constexpr bool is_final_v = __is_final(T); |
| 160 |
|
| 161 |
template <typename T> |
| 162 |
struct __details_is_abstract { |
| 163 |
static constexpr bool value = __is_abstract(T); |
| 164 |
}; |
| 165 |
template <typename T> |
| 166 |
using is_abstract = __details_is_abstract<T>; |
| 167 |
template <typename T> |
| 168 |
constexpr bool is_abstract_v = __is_abstract(T); |
| 169 |
|
| 170 |
#endif |
| 171 |
|
| 172 |
|
| 173 |
#ifdef STD3 |
| 174 |
template< class T, T v > |
| 175 |
struct integral_constant { |
| 176 |
static constexpr T value = v; |
| 177 |
}; |
| 178 |
|
| 179 |
template< bool B > |
| 180 |
using bool_constant = integral_constant<bool, B>; |
| 181 |
|
| 182 |
template <typename T> |
| 183 |
struct __details_is_trivially_relocatable : bool_constant<__builtin_is_cpp_trivially_relocatable(T)> {}; |
| 184 |
|
| 185 |
template <typename T> |
| 186 |
using is_trivially_relocatable = __details_is_trivially_relocatable<T>; |
| 187 |
|
| 188 |
template <typename T> |
| 189 |
constexpr bool is_trivially_relocatable_v = is_trivially_relocatable<T>::value; |
| 190 |
|
| 191 |
template <typename T> |
| 192 |
struct __details_is_trivially_copyable : bool_constant<__is_trivially_copyable(T)> {}; |
| 193 |
|
| 194 |
template <typename T> |
| 195 |
using is_trivially_copyable = __details_is_trivially_copyable<T>; |
| 196 |
|
| 197 |
template <typename T> |
| 198 |
constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value; |
| 199 |
|
| 200 |
template <typename T, typename U> |
| 201 |
struct __details_is_assignable : bool_constant<__is_assignable(T, U)> {}; |
| 202 |
|
| 203 |
template <typename T, typename U> |
| 204 |
using is_assignable = __details_is_assignable<T, U>; |
| 205 |
|
| 206 |
template <typename T, typename U> |
| 207 |
constexpr bool is_assignable_v = is_assignable<T, U>::value; |
| 208 |
|
| 209 |
template <typename T> |
| 210 |
struct __details_is_empty : bool_constant<__is_empty(T)> {}; |
| 211 |
template <typename T> |
| 212 |
using is_empty = __details_is_empty<T>; |
| 213 |
template <typename T> |
| 214 |
constexpr bool is_empty_v = is_empty<T>::value; |
| 215 |
|
| 216 |
template <typename T> |
| 217 |
struct __details_is_standard_layout : bool_constant<__is_standard_layout(T)> {}; |
| 218 |
template <typename T> |
| 219 |
using is_standard_layout = __details_is_standard_layout<T>; |
| 220 |
template <typename T> |
| 221 |
constexpr bool is_standard_layout_v = is_standard_layout<T>::value; |
| 222 |
|
| 223 |
template <typename... Args> |
| 224 |
struct __details_is_constructible : bool_constant<__is_constructible(Args...)> {}; |
| 225 |
|
| 226 |
template <typename... Args> |
| 227 |
using is_constructible = __details_is_constructible<Args...>; |
| 228 |
|
| 229 |
template <typename... Args> |
| 230 |
constexpr bool is_constructible_v = is_constructible<Args...>::value; |
| 231 |
|
| 232 |
template <typename T> |
| 233 |
struct __details_is_aggregate : bool_constant<__is_aggregate(T)> {}; |
| 234 |
|
| 235 |
template <typename T> |
| 236 |
using is_aggregate = __details_is_aggregate<T>; |
| 237 |
|
| 238 |
template <typename T> |
| 239 |
constexpr bool is_aggregate_v = is_aggregate<T>::value; |
| 240 |
|
| 241 |
template <typename T> |
| 242 |
struct __details_is_final : bool_constant<__is_final(T)> {}; |
| 243 |
template <typename T> |
| 244 |
using is_final = __details_is_final<T>; |
| 245 |
template <typename T> |
| 246 |
constexpr bool is_final_v = is_final<T>::value; |
| 247 |
|
| 248 |
template <typename T> |
| 249 |
struct __details_is_abstract : bool_constant<__is_abstract(T)> {}; |
| 250 |
template <typename T> |
| 251 |
using is_abstract = __details_is_abstract<T>; |
| 252 |
template <typename T> |
| 253 |
constexpr bool is_abstract_v = is_abstract<T>::value; |
| 254 |
|
| 255 |
#endif |
| 256 |
} |
| 257 |
|
| 258 |
static_assert(std::is_trivially_relocatable<int>::value); |
| 259 |
|
| 260 |
static_assert(std::is_trivially_relocatable<int&>::value); |
| 261 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_trivially_relocatable<int &>::value'}} \ |
| 262 |
// expected-note@-1 {{'int &' is not trivially relocatable}} \ |
| 263 |
// expected-note@-1 {{because it is a reference type}} |
| 264 |
static_assert(std::is_trivially_relocatable_v<int&>); |
| 265 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_trivially_relocatable_v<int &>'}} \ |
| 266 |
// expected-note@-1 {{'int &' is not trivially relocatable}} \ |
| 267 |
// expected-note@-1 {{because it is a reference type}} |
| 268 |
|
| 269 |
static_assert(std::is_trivially_copyable<int>::value); |
| 270 |
|
| 271 |
static_assert(std::is_trivially_copyable<int&>::value); |
| 272 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_trivially_copyable<int &>::value'}} \ |
| 273 |
// expected-note@-1 {{'int &' is not trivially copyable}} \ |
| 274 |
// expected-note@-1 {{because it is a reference type}} |
| 275 |
static_assert(std::is_trivially_copyable_v<int&>); |
| 276 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_trivially_copyable_v<int &>'}} \ |
| 277 |
// expected-note@-1 {{'int &' is not trivially copyable}} \ |
| 278 |
// expected-note@-1 {{because it is a reference type}} |
| 279 |
|
| 280 |
|
| 281 |
// Direct tests |
| 282 |
static_assert(std::is_standard_layout<int>::value); |
| 283 |
static_assert(std::is_standard_layout_v<int>); |
| 284 |
|
| 285 |
static_assert(std::is_standard_layout<int&>::value); |
| 286 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_standard_layout<int &>::value'}} \ |
| 287 |
// expected-note@-1 {{'int &' is not standard-layout}} \ |
| 288 |
// expected-note@-1 {{because it is a reference type}} |
| 289 |
|
| 290 |
static_assert(std::is_standard_layout_v<int&>); |
| 291 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_standard_layout_v<int &>'}} \ |
| 292 |
// expected-note@-1 {{'int &' is not standard-layout}} \ |
| 293 |
// expected-note@-1 {{because it is a reference type}} |
| 294 |
|
| 295 |
static_assert(!std::is_empty<int>::value); |
| 296 |
|
| 297 |
static_assert(std::is_empty<int&>::value); |
| 298 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_empty<int &>::value'}} \ |
| 299 |
// expected-note@-1 {{'int &' is not empty}} \ |
| 300 |
// expected-note@-1 {{because it is a reference type}} |
| 301 |
static_assert(std::is_empty_v<int&>); |
| 302 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_empty_v<int &>'}} \ |
| 303 |
// expected-note@-1 {{'int &' is not empty}} \ |
| 304 |
// expected-note@-1 {{because it is a reference type}} |
| 305 |
|
| 306 |
|
| 307 |
static_assert(std::is_assignable<int&, int>::value); |
| 308 |
|
| 309 |
static_assert(std::is_assignable<int&, void>::value); |
| 310 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_assignable<int &, void>::value'}} \ |
| 311 |
// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}} |
| 312 |
static_assert(std::is_assignable_v<int&, void>); |
| 313 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_assignable_v<int &, void>'}} \ |
| 314 |
// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}} |
| 315 |
|
| 316 |
static_assert(std::is_constructible<int, int>::value); |
| 317 |
|
| 318 |
static_assert(std::is_constructible<void>::value); |
| 319 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_constructible<void>::value'}} \ |
| 320 |
// expected-note@-1 {{because it is a cv void type}} |
| 321 |
static_assert(std::is_constructible_v<void>); |
| 322 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_constructible_v<void>'}} \ |
| 323 |
// expected-note@-1 {{because it is a cv void type}} |
| 324 |
|
| 325 |
static_assert(!std::is_final<int>::value); |
| 326 |
|
| 327 |
static_assert(std::is_final<int&>::value); |
| 328 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_final<int &>::value'}} \ |
| 329 |
// expected-note@-1 {{'int &' is not final}} \ |
| 330 |
// expected-note@-1 {{because it is a reference type}} \ |
| 331 |
// expected-note@-1 {{because it is not a class or union type}} |
| 332 |
|
| 333 |
static_assert(std::is_final_v<int&>); |
| 334 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_final_v<int &>'}} \ |
| 335 |
// expected-note@-1 {{'int &' is not final}} \ |
| 336 |
// expected-note@-1 {{because it is a reference type}} \ |
| 337 |
// expected-note@-1 {{because it is not a class or union type}} |
| 338 |
|
| 339 |
using Arr = int[3]; |
| 340 |
static_assert(std::is_final<Arr>::value); |
| 341 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_final<int[3]>::value'}} \ |
| 342 |
// expected-note@-1 {{'Arr' (aka 'int[3]') is not final}} \ |
| 343 |
// expected-note@-1 {{because it is not a class or union type}} |
| 344 |
|
| 345 |
static_assert(std::is_final_v<Arr>); |
| 346 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_final_v<int[3]>'}} \ |
| 347 |
// expected-note@-1 {{'int[3]' is not final}} \ |
| 348 |
// expected-note@-1 {{because it is not a class or union type}} |
| 349 |
|
| 350 |
|
| 351 |
static_assert(!std::is_aggregate<int>::value); |
| 352 |
|
| 353 |
static_assert(std::is_aggregate<void>::value); |
| 354 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_aggregate<void>::value'}} \ |
| 355 |
// expected-note@-1 {{'void' is not aggregate}} \ |
| 356 |
// expected-note@-1 {{because it is a cv void type}} |
| 357 |
static_assert(std::is_aggregate_v<void>); |
| 358 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_aggregate_v<void>'}} \ |
| 359 |
// expected-note@-1 {{'void' is not aggregate}} \ |
| 360 |
// expected-note@-1 {{because it is a cv void type}} |
| 361 |
|
| 362 |
|
| 363 |
static_assert(!std::is_abstract<int>::value); |
| 364 |
|
| 365 |
static_assert(std::is_abstract<int&>::value); |
| 366 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_abstract<int &>::value'}} \ |
| 367 |
// expected-note@-1 {{'int &' is not abstract}} \ |
| 368 |
// expected-note@-1 {{because it is a reference type}} \ |
| 369 |
// expected-note@-1 {{because it is not a struct or class type}} |
| 370 |
|
| 371 |
static_assert(std::is_abstract_v<int&>); |
| 372 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_abstract_v<int &>'}} \ |
| 373 |
// expected-note@-1 {{'int &' is not abstract}} \ |
| 374 |
// expected-note@-1 {{because it is a reference type}} \ |
| 375 |
// expected-note@-1 {{because it is not a struct or class type}} |
| 376 |
|
| 377 |
|
| 378 |
namespace test_namespace { |
| 379 |
using namespace std; |
| 380 |
static_assert(is_trivially_relocatable<int&>::value); |
| 381 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_trivially_relocatable<int &>::value'}} \ |
| 382 |
// expected-note@-1 {{'int &' is not trivially relocatable}} \ |
| 383 |
// expected-note@-1 {{because it is a reference type}} |
| 384 |
static_assert(is_trivially_relocatable_v<int&>); |
| 385 |
// expected-error@-1 {{static assertion failed due to requirement 'is_trivially_relocatable_v<int &>'}} \ |
| 386 |
// expected-note@-1 {{'int &' is not trivially relocatable}} \ |
| 387 |
// expected-note@-1 {{because it is a reference type}} |
| 388 |
|
| 389 |
static_assert(is_trivially_copyable<int&>::value); |
| 390 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_trivially_copyable<int &>::value'}} \ |
| 391 |
// expected-note@-1 {{'int &' is not trivially copyable}} \ |
| 392 |
// expected-note@-1 {{because it is a reference type}} |
| 393 |
static_assert(is_trivially_copyable_v<int&>); |
| 394 |
// expected-error@-1 {{static assertion failed due to requirement 'is_trivially_copyable_v<int &>'}} \ |
| 395 |
// expected-note@-1 {{'int &' is not trivially copyable}} \ |
| 396 |
// expected-note@-1 {{because it is a reference type}} |
| 397 |
|
| 398 |
static_assert(is_standard_layout<int&>::value); |
| 399 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_standard_layout<int &>::value'}} \ |
| 400 |
// expected-note@-1 {{'int &' is not standard-layout}} \ |
| 401 |
// expected-note@-1 {{because it is a reference type}} |
| 402 |
|
| 403 |
static_assert(is_standard_layout_v<int&>); |
| 404 |
// expected-error@-1 {{static assertion failed due to requirement 'is_standard_layout_v<int &>'}} \ |
| 405 |
// expected-note@-1 {{'int &' is not standard-layout}} \ |
| 406 |
// expected-note@-1 {{because it is a reference type}} |
| 407 |
|
| 408 |
static_assert(is_assignable<int&, void>::value); |
| 409 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_assignable<int &, void>::value'}} \ |
| 410 |
// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}} |
| 411 |
static_assert(is_assignable_v<int&, void>); |
| 412 |
// expected-error@-1 {{static assertion failed due to requirement 'is_assignable_v<int &, void>'}} \ |
| 413 |
// expected-error@-1 {{assigning to 'int' from incompatible type 'void'}} |
| 414 |
|
| 415 |
static_assert(is_empty<int&>::value); |
| 416 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_empty<int &>::value'}} \ |
| 417 |
// expected-note@-1 {{'int &' is not empty}} \ |
| 418 |
// expected-note@-1 {{because it is a reference type}} |
| 419 |
static_assert(is_empty_v<int&>); |
| 420 |
// expected-error@-1 {{static assertion failed due to requirement 'is_empty_v<int &>'}} \ |
| 421 |
// expected-note@-1 {{'int &' is not empty}} \ |
| 422 |
// expected-note@-1 {{because it is a reference type}} |
| 423 |
|
| 424 |
static_assert(is_constructible<void>::value); |
| 425 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_constructible<void>::value'}} \ |
| 426 |
// expected-note@-1 {{because it is a cv void type}} |
| 427 |
static_assert(is_constructible_v<void>); |
| 428 |
// expected-error@-1 {{static assertion failed due to requirement 'is_constructible_v<void>'}} \ |
| 429 |
// expected-note@-1 {{because it is a cv void type}} |
| 430 |
|
| 431 |
static_assert(std::is_aggregate<void>::value); |
| 432 |
// expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_aggregate<void>::value'}} \ |
| 433 |
// expected-note@-1 {{'void' is not aggregate}} \ |
| 434 |
// expected-note@-1 {{because it is a cv void type}} |
| 435 |
static_assert(std::is_aggregate_v<void>); |
| 436 |
// expected-error@-1 {{static assertion failed due to requirement 'std::is_aggregate_v<void>'}} \ |
| 437 |
// expected-note@-1 {{'void' is not aggregate}} \ |
| 438 |
// expected-note@-1 {{because it is a cv void type}} |
| 439 |
|
| 440 |
static_assert(is_final<int&>::value); |
| 441 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<int &>::value'}} \ |
| 442 |
// expected-note@-1 {{'int &' is not final}} \ |
| 443 |
// expected-note@-1 {{because it is a reference type}} \ |
| 444 |
// expected-note@-1 {{because it is not a class or union type}} |
| 445 |
|
| 446 |
static_assert(is_final_v<int&>); |
| 447 |
// expected-error@-1 {{static assertion failed due to requirement 'is_final_v<int &>'}} \ |
| 448 |
// expected-note@-1 {{'int &' is not final}} \ |
| 449 |
// expected-note@-1 {{because it is a reference type}} \ |
| 450 |
// expected-note@-1 {{because it is not a class or union type}} |
| 451 |
|
| 452 |
using A = int[2]; |
| 453 |
static_assert(is_final<A>::value); |
| 454 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<int[2]>::value'}} \ |
| 455 |
// expected-note@-1 {{'A' (aka 'int[2]') is not final}} \ |
| 456 |
// expected-note@-1 {{because it is not a class or union type}} |
| 457 |
|
| 458 |
using Fn = void(); |
| 459 |
static_assert(is_final<Fn>::value); |
| 460 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<void ()>::value'}} \ |
| 461 |
// expected-note@-1 {{'Fn' (aka 'void ()') is not final}} \ |
| 462 |
// expected-note@-1 {{because it is a function type}} \ |
| 463 |
// expected-note@-1 {{because it is not a class or union type}} |
| 464 |
|
| 465 |
static_assert(is_abstract<int&>::value); |
| 466 |
// expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_abstract<int &>::value'}} \ |
| 467 |
// expected-note@-1 {{'int &' is not abstract}} \ |
| 468 |
// expected-note@-1 {{because it is a reference type}} \ |
| 469 |
// expected-note@-1 {{because it is not a struct or class type}} |
| 470 |
|
| 471 |
static_assert(is_abstract_v<int&>); |
| 472 |
// expected-error@-1 {{static assertion failed due to requirement 'is_abstract_v<int &>'}} \ |
| 473 |
// expected-note@-1 {{'int &' is not abstract}} \ |
| 474 |
// expected-note@-1 {{because it is a reference type}} \ |
| 475 |
// expected-note@-1 {{because it is not a struct or class type}} |
| 476 |
} |
| 477 |
|
| 478 |
|
| 479 |
namespace concepts { |
| 480 |
template <typename T> |
| 481 |
requires std::is_trivially_relocatable<T>::value void f(); // #cand1 |
| 482 |
|
| 483 |
template <typename T> |
| 484 |
concept C = std::is_trivially_relocatable_v<T>; // #concept2 |
| 485 |
|
| 486 |
template <C T> void g(); // #cand2 |
| 487 |
|
| 488 |
template <typename T> |
| 489 |
requires std::is_trivially_copyable<T>::value void f2(); // #cand3 |
| 490 |
|
| 491 |
template <typename T> |
| 492 |
concept C2 = std::is_trivially_copyable_v<T>; // #concept4 |
| 493 |
|
| 494 |
template <C2 T> void g2(); // #cand4 |
| 495 |
|
| 496 |
template <typename T, typename U> |
| 497 |
requires std::is_assignable<T, U>::value void f4(); // #cand7 |
| 498 |
|
| 499 |
template <typename T, typename U> |
| 500 |
concept C4 = std::is_assignable_v<T, U>; // #concept8 |
| 501 |
|
| 502 |
template <C4<void> T> void g4(); // #cand8 |
| 503 |
|
| 504 |
template <typename... Args> |
| 505 |
requires std::is_constructible<Args...>::value void f3(); // #cand5 |
| 506 |
|
| 507 |
template <typename... Args> |
| 508 |
concept C3 = std::is_constructible_v<Args...>; // #concept6 |
| 509 |
|
| 510 |
template <C3 T> void g3(); // #cand6 |
| 511 |
|
| 512 |
|
| 513 |
template <typename T> |
| 514 |
requires std::is_aggregate<T>::value void f5(); // #cand9 |
| 515 |
|
| 516 |
template <typename T> |
| 517 |
concept C5 = std::is_aggregate_v<T>; // #concept10 |
| 518 |
|
| 519 |
template <C5 T> void g5(); // #cand10 |
| 520 |
|
| 521 |
void test() { |
| 522 |
f<int&>(); |
| 523 |
// expected-error@-1 {{no matching function for call to 'f'}} \ |
| 524 |
// expected-note@#cand1 {{candidate template ignored: constraints not satisfied [with T = int &]}} \ |
| 525 |
// expected-note-re@#cand1 {{because '{{.*}}is_trivially_relocatable<int &>::value' evaluated to false}} \ |
| 526 |
// expected-note@#cand1 {{'int &' is not trivially relocatable}} \ |
| 527 |
// expected-note@#cand1 {{because it is a reference type}} |
| 528 |
|
| 529 |
g<int&>(); |
| 530 |
// expected-error@-1 {{no matching function for call to 'g'}} \ |
| 531 |
// expected-note@#cand2 {{candidate template ignored: constraints not satisfied [with T = int &]}} \ |
| 532 |
// expected-note@#cand2 {{because 'int &' does not satisfy 'C'}} \ |
| 533 |
// expected-note@#concept2 {{because 'std::is_trivially_relocatable_v<int &>' evaluated to false}} \ |
| 534 |
// expected-note@#concept2 {{'int &' is not trivially relocatable}} \ |
| 535 |
// expected-note@#concept2 {{because it is a reference type}} |
| 536 |
|
| 537 |
f2<int&>(); |
| 538 |
// expected-error@-1 {{no matching function for call to 'f2'}} \ |
| 539 |
// expected-note@#cand3 {{candidate template ignored: constraints not satisfied [with T = int &]}} \ |
| 540 |
// expected-note-re@#cand3 {{because '{{.*}}is_trivially_copyable<int &>::value' evaluated to false}} \ |
| 541 |
// expected-note@#cand3 {{'int &' is not trivially copyable}} \ |
| 542 |
// expected-note@#cand3 {{because it is a reference type}} |
| 543 |
|
| 544 |
g2<int&>(); |
| 545 |
// expected-error@-1 {{no matching function for call to 'g2'}} \ |
| 546 |
// expected-note@#cand4 {{candidate template ignored: constraints not satisfied [with T = int &]}} \ |
| 547 |
// expected-note@#cand4 {{because 'int &' does not satisfy 'C2'}} \ |
| 548 |
// expected-note@#concept4 {{because 'std::is_trivially_copyable_v<int &>' evaluated to false}} \ |
| 549 |
// expected-note@#concept4 {{'int &' is not trivially copyable}} \ |
| 550 |
// expected-note@#concept4 {{because it is a reference type}} |
| 551 |
|
| 552 |
f4<int&, void>(); |
| 553 |
// expected-error@-1 {{no matching function for call to 'f4'}} \ |
| 554 |
// expected-note@#cand7 {{candidate template ignored: constraints not satisfied [with T = int &, U = void]}} \ |
| 555 |
// expected-note-re@#cand7 {{because '{{.*}}is_assignable<int &, void>::value' evaluated to false}} \ |
| 556 |
// expected-error@#cand7 {{assigning to 'int' from incompatible type 'void'}} |
| 557 |
|
| 558 |
g4<int&>(); |
| 559 |
// expected-error@-1 {{no matching function for call to 'g4'}} \ |
| 560 |
// expected-note@#cand8 {{candidate template ignored: constraints not satisfied [with T = int &]}} \ |
| 561 |
// expected-note@#cand8 {{because 'C4<int &, void>' evaluated to false}} \ |
| 562 |
// expected-note@#concept8 {{because 'std::is_assignable_v<int &, void>' evaluated to false}} \ |
| 563 |
// expected-error@#concept8 {{assigning to 'int' from incompatible type 'void'}} |
| 564 |
|
| 565 |
f3<void>(); |
| 566 |
// expected-error@-1 {{no matching function for call to 'f3'}} \ |
| 567 |
// expected-note@#cand5 {{candidate template ignored: constraints not satisfied [with Args = <void>]}} \ |
| 568 |
// expected-note-re@#cand5 {{because '{{.*}}is_constructible<void>::value' evaluated to false}} \ |
| 569 |
// expected-note@#cand5 {{because it is a cv void type}} |
| 570 |
|
| 571 |
g3<void>(); |
| 572 |
// expected-error@-1 {{no matching function for call to 'g3'}} \ |
| 573 |
// expected-note@#cand6 {{candidate template ignored: constraints not satisfied [with T = void]}} \ |
| 574 |
// expected-note@#cand6 {{because 'void' does not satisfy 'C3'}} \ |
| 575 |
// expected-note@#concept6 {{because 'std::is_constructible_v<void>' evaluated to false}} \ |
| 576 |
// expected-note@#concept6 {{because it is a cv void type}} |
| 577 |
|
| 578 |
f5<void>(); |
| 579 |
// expected-error@-1 {{no matching function for call to 'f5'}} \ |
| 580 |
// expected-note@#cand9 {{candidate template ignored: constraints not satisfied [with T = void]}} \ |
| 581 |
// expected-note-re@#cand9 {{because '{{.*}}is_aggregate<void>::value' evaluated to false}} \ |
| 582 |
// expected-note@#cand9 {{'void' is not aggregate}} \ |
| 583 |
// expected-note@#cand9 {{because it is a cv void type}} |
| 584 |
|
| 585 |
g5<void>(); |
| 586 |
// expected-error@-1 {{no matching function for call to 'g5'}} \ |
| 587 |
// expected-note@#cand10 {{candidate template ignored: constraints not satisfied [with T = void]}} \ |
| 588 |
// expected-note@#cand10 {{because 'void' does not satisfy 'C5'}} \ |
| 589 |
// expected-note@#concept10 {{because 'std::is_aggregate_v<void>' evaluated to false}} \ |
| 590 |
// expected-note@#concept10 {{'void' is not aggregate}} \ |
| 591 |
// expected-note@#concept10 {{because it is a cv void type}} |
| 592 |
} |
| 593 |
} |