std::is_final
Defined in header <type_traits> | | |
|---|---|---|
template< class T > struct is_final; | | (since C++14) |
如果T是最后一个类%28,即用最终说明符%29,提供成员常量。value平等true.对于任何其他类型,value是false...
如果T是类类型,T应该是一个完整的类型;否则,该行为是未定义的。
模板参数
T | - | a type to check |
|---|
辅助变量模板
template< class T > inline constexpr bool is_final_v = is_final<T>::value; | | (since C++17) |
|---|
继承自STD:积分[医]常量
成员常数
value static | true if T is a final class type , false otherwise (public static member constant) |
|---|
成员函数
operator bool | converts the object to bool, returns value (public member function) |
|---|---|
operator() (C++14) | returns value (public member function) |
成员类型
Type | Definition |
|---|---|
value_type | bool |
type | std::integral_constant<bool, value> |
注记
最后类不能用作基类。
阿联合可以标记final28%和std::is_final将检测到%29,即使联合在任何情况下都不能用作基。
例
二次
#include <iostream>
#include <type_traits>
class A {};
class B final {};
int main()
{
std::cout
<< std::boolalpha
<< std::is_final<A>::value << '\n'
<< std::is_final<B>::value << '\n';
}二次
产出:
二次
false
true二次
另见
is_class (C++11) | checks if a type is a non-union class type (class template) |
|---|---|
is_polymorphic (C++11) | checks if a type is polymorphic class type (class template) |
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

