@@ -50,6 +50,14 @@ struct is_constructible {
5050
5151template <typename ... Args>
5252constexpr 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+
5361#endif
5462
5563#ifdef STD2
@@ -116,6 +124,16 @@ using is_constructible = __details_is_constructible<Args...>;
116124
117125template <typename ... Args>
118126constexpr 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+
119137#endif
120138
121139
@@ -177,6 +195,14 @@ using is_constructible = __details_is_constructible<Args...>;
177195
178196template <typename ... Args>
179197constexpr 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+
180206#endif
181207
182208}
@@ -248,6 +274,31 @@ static_assert(std::is_constructible_v<void>);
248274// expected-error@-1 {{static assertion failed due to requirement 'std::is_constructible_v<void>'}} \
249275// expected-note@-1 {{because it is a cv void type}}
250276
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+
251302namespace test_namespace {
252303 using namespace std ;
253304 static_assert (is_trivially_relocatable<int &>::value);
@@ -300,6 +351,31 @@ namespace test_namespace {
300351 static_assert (is_constructible_v<void >);
301352 // expected-error@-1 {{static assertion failed due to requirement 'is_constructible_v<void>'}} \
302353 // 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}}
303379}
304380
305381
0 commit comments