| Home | Libraries | People | FAQ | More

### is_final

    template <class T>
    struct is_final : public true_type-or-false_type {};

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 `BOOST_IS_FINAL` is defined.

Header: `#include <boost/type_traits/is_final.hpp>` or `#include <boost/type_traits.hpp>`

Examples:

Given `struct my_final final {};` then:

> `is_final<my_final>` inherits from `true_type`.

> `is_final<const my_final>::type` is the type `true_type`.

> `is_final<my_final>::value` is an integral constant expression that evaluates to true.

> `is_final<my_final*>::value` is an integral constant expression that evaluates to false.

> `is_final<T>::value_type` is the type `bool`.