@@ -50,6 +50,14 @@ struct is_constructible {
50
50
51
51
template <typename ... Args>
52
52
constexpr bool is_constructible_v = __is_constructible(Args...);
53
+
54
+ template <typename T>
55
+ struct is_final {
56
+ static constexpr bool value = __is_final(T);
57
+ };
58
+ template <typename T>
59
+ constexpr bool is_final_v = __is_final(T);
60
+
53
61
#endif
54
62
55
63
#ifdef STD2
@@ -116,6 +124,16 @@ using is_constructible = __details_is_constructible<Args...>;
116
124
117
125
template <typename ... Args>
118
126
constexpr bool is_constructible_v = __is_constructible(Args...);
127
+
128
+ template <typename T>
129
+ struct __details_is_final {
130
+ static constexpr bool value = __is_final(T);
131
+ };
132
+ template <typename T>
133
+ using is_final = __details_is_final<T>;
134
+ template <typename T>
135
+ constexpr bool is_final_v = __is_final(T);
136
+
119
137
#endif
120
138
121
139
@@ -177,6 +195,14 @@ using is_constructible = __details_is_constructible<Args...>;
177
195
178
196
template <typename ... Args>
179
197
constexpr bool is_constructible_v = is_constructible<Args...>::value;
198
+
199
+ template <typename T>
200
+ struct __details_is_final : bool_constant<__is_final(T)> {};
201
+ template <typename T>
202
+ using is_final = __details_is_final<T>;
203
+ template <typename T>
204
+ constexpr bool is_final_v = is_final<T>::value;
205
+
180
206
#endif
181
207
182
208
}
@@ -248,6 +274,31 @@ static_assert(std::is_constructible_v<void>);
248
274
// expected-error@-1 {{static assertion failed due to requirement 'std::is_constructible_v<void>'}} \
249
275
// expected-note@-1 {{because it is a cv void type}}
250
276
277
+ static_assert (!std::is_final<int >::value);
278
+
279
+ static_assert (std::is_final<int &>::value);
280
+ // expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_final<int &>::value'}} \
281
+ // expected-note@-1 {{'int &' is not final}} \
282
+ // expected-note@-1 {{because it is a reference type}} \
283
+ // expected-note@-1 {{because it is not a class or union type}}
284
+
285
+ static_assert (std::is_final_v<int &>);
286
+ // expected-error@-1 {{static assertion failed due to requirement 'std::is_final_v<int &>'}} \
287
+ // expected-note@-1 {{'int &' is not final}} \
288
+ // expected-note@-1 {{because it is a reference type}} \
289
+ // expected-note@-1 {{because it is not a class or union type}}
290
+
291
+ using Arr = int [3 ];
292
+ static_assert (std::is_final<Arr>::value);
293
+ // expected-error-re@-1 {{static assertion failed due to requirement 'std::{{.*}}is_final<int[3]>::value'}} \
294
+ // expected-note@-1 {{'Arr' (aka 'int[3]') is not final}} \
295
+ // expected-note@-1 {{because it is not a class or union type}}
296
+
297
+ static_assert (std::is_final_v<Arr>);
298
+ // expected-error@-1 {{static assertion failed due to requirement 'std::is_final_v<int[3]>'}} \
299
+ // expected-note@-1 {{'int[3]' is not final}} \
300
+ // expected-note@-1 {{because it is not a class or union type}}
301
+
251
302
namespace test_namespace {
252
303
using namespace std ;
253
304
static_assert (is_trivially_relocatable<int &>::value);
@@ -300,6 +351,31 @@ namespace test_namespace {
300
351
static_assert (is_constructible_v<void >);
301
352
// expected-error@-1 {{static assertion failed due to requirement 'is_constructible_v<void>'}} \
302
353
// expected-note@-1 {{because it is a cv void type}}
354
+
355
+ static_assert (is_final<int &>::value);
356
+ // expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<int &>::value'}} \
357
+ // expected-note@-1 {{'int &' is not final}} \
358
+ // expected-note@-1 {{because it is a reference type}} \
359
+ // expected-note@-1 {{because it is not a class or union type}}
360
+
361
+ static_assert (is_final_v<int &>);
362
+ // expected-error@-1 {{static assertion failed due to requirement 'is_final_v<int &>'}} \
363
+ // expected-note@-1 {{'int &' is not final}} \
364
+ // expected-note@-1 {{because it is a reference type}} \
365
+ // expected-note@-1 {{because it is not a class or union type}}
366
+
367
+ using A = int [2 ];
368
+ static_assert (is_final<A>::value);
369
+ // expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<int[2]>::value'}} \
370
+ // expected-note@-1 {{'A' (aka 'int[2]') is not final}} \
371
+ // expected-note@-1 {{because it is not a class or union type}}
372
+
373
+ using Fn = void ();
374
+ static_assert (is_final<Fn>::value);
375
+ // expected-error-re@-1 {{static assertion failed due to requirement '{{.*}}is_final<void ()>::value'}} \
376
+ // expected-note@-1 {{'Fn' (aka 'void ()') is not final}} \
377
+ // expected-note@-1 {{because it is a function type}} \
378
+ // expected-note@-1 {{because it is not a class or union type}}
303
379
}
304
380
305
381
0 commit comments