Spec-Zone.ru › C++

std::meta::is_final_type

Defined in header <meta>
consteval bool is_final_type( std::meta::info r );
(since C++26)

Returns true if r represents a final class type. Otherwise returns false.

Parameters

r - a reflection value

Return value

true if r represents a final class type; otherwise false.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Example

#include <meta>

class A {};
static_assert(is_final_type(^^A) == false);

class B final {};
static_assert(is_final_type(^^B) == true);

union U final
{
    int x;
    double d;
};
static_assert(is_final_type(^^U) == true);

struct Base
{
    virtual void foo();
};

struct Derived : Base
{
    void foo() final; // final member function does not make the class final
};
static_assert(is_final_type(^^Derived) == false);

int main() {}

See also

is_final
(C++14)
checks if a type is a final class type
(class template)
is_class_type
(C++26)
checks if reflected type is a non-union class type
(function)
is_union_type
(C++26)
checks if reflected type is a union type
(function)
is_polymorphic_type
(C++26)
checks if reflected type is a polymorphic class type
(function)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/is_final_type

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API