...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
template <class T> struct is_final : public
Inherits: If T is a (possibly cv-qualified) class type declared with the final specifier type then inherits from true_type, otherwise inherits from false_type. Currently requires some kind of compiler support.
C++ Standard Reference: 9p3.
Compiler Compatibility: Without (some as
yet unspecified) help from the compiler, we cannot detect class types declared
with the final specifier using only standard C++, as a result this type will
never inherit from true_type,
unless the user explicitly specializes the template for their user-defined
final class types, or unless the compiler supplies some unspecified intrinsic
that implements this functionality. Currently (June 2015) compilers more
recent than GCC-4.7, Oracle-12.4, and Clang have the necessary compiler
intrinsics to ensure that
this trait "just works". You may also test to see if the necessary
intrinsics are available
by checking to see if the macro
is_final<const my_final>::typeis the type
is_final<my_final>::valueis an integral constant expression that evaluates to true.
is_final<my_final*>::valueis an integral constant expression that evaluates to false.
is_final<T>::value_typeis the type