Namespaces
Variants

std:: is_final

From ja.cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
is_final
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
ヘッダーで定義 <type_traits>
template < class T >
struct is_final ;
(C++14以降)

std::is_final は UnaryTypeTrait です。

T が final クラスである場合、メンバ定数 value を true に設定します。それ以外の型の場合、 value は false となります。

T が不完全クラス型の場合、動作は未定義です。

プログラムが std::is_final または std::is_final_v (C++17以降) に対する特殊化を追加する場合、動作は未定義です。

目次

テンプレートパラメータ

T - チェックする型

ヘルパー変数テンプレート

template < class T >
constexpr bool is_final_v = is_final < T > :: value ;
(C++17以降)

std:: integral_constant から継承

メンバ定数

value
[static]
true ( T がfinalクラス型の場合)、 false (それ以外の場合)
(public static member constant)

メンバ関数

operator bool
オブジェクトを bool に変換し、 value を返す
(public member function)
operator()
(C++14)
value を返す
(public member function)

メンバ型

型 定義
value_type bool
type std:: integral_constant < bool , value >

注記

std::is_final は、 LWG issue 2112 の解決によって導入されました。

union は final と宣言することができます(そして std::is_final はそれを検出します)、たとえunionがどのような場合でも基底クラスとして使用できないとしても。

機能テスト マクロ 値 標準 機能
__cpp_lib_is_final 201402L (C++14) std::is_final

例

#include <type_traits>
class A {};
static_assert(std::is_final_v<A> == false);
class B final {};
static_assert(std::is_final_v<B> == true);
union U final
{
    int x;
    double d;
};
static_assert(std::is_final_v<U> == true);
int main()
{
}

関連項目

(C++11)
型が非共用体クラス型かどうかをチェックする
(クラステンプレート)
型がポリモーフィックなクラス型かどうかをチェックする
(クラステンプレート)