From cppreference.com
template<classT>structis_final;(since C++14)std::is_final is a
.
If T is a
class, provides the member constant value equal true. For any other type, value is false.
If T is an incomplete class type, the behavior is undefined.
If the program adds specializations for std::is_final or std::is_final_v(since C++17), the behavior is undefined.
Template parameters
T - a type to check Helper variable template
template<classT>constexprboolis_final_v=is_final<T>::value;(since C++17)Inherited from
Member constants
value
[static]
true if T is a final class type, false otherwise
(public static member constant)Member functions
operator bool
converts the object to bool, returns value
(public member function)operator()
(C++14)
returns value
(public member function)Member types
Type Definition value_typebooltypestd::integral_constant<bool,value>Notes
std::is_final is introduced by the resolution of
.
A
can be declared final (and std::is_final will detect that), even though unions cannot be used as bases in any case.
macroValueStdFeature
(C++14)std::is_finalExample
Run this code
#include<type_traits>classA{};static_assert(std::is_final_v<A>==false);classBfinal{};static_assert(std::is_final_v<B>==true);unionUfinal{intx;doubled;};static_assert(std::is_final_v<U>==true);intmain(){}See also