std::is_final(3)
π std::is_final(3) β C++ Standard Library, bestie πβ¨
Okay so this is the manual page for std::is_final in the C++ Standard Library, and itβs giving βtiny trait, huge main character energy.β π
πΈ NAME πΈ
std::is_final β literally the trait that checks whether a type is final. Thatβs the whole name, no cap. π
β¨ Synopsis β¨
Defined in header <type_traits>.
template< class T > (since C++14)
struct is_final;
std::is_final is a UnaryTypeTrait.
If T is a final class, it provides the member constant value equal true. For any other type, value is false.
β οΈ If T is an incomplete class type, the behavior is undefined. Not a vibe. π
β οΈ If the program adds specializations forstd::is_finalorstd::is_final_v(since C++17), the behavior is undefined. Do not do this, bestie. π
π§ Template parameters π§
Tβ a type to check.
π Helper variable template π
template< class T > (since C++17)
inline constexpr bool is_final_v = is_final<T>::value;
𧬠Inherited from std::integral_constant π§¬
This trait inherits from std::integral_constant, iykyk. β¨
π Member constants π
valueβtrueifTis a final class type,falseotherwise.[static](public static member constant).
π Member functions π
operator boolβ converts the object tobool, returnsvalue(public member function).operator()β returnsvalue(C++14) (public member function).
π¦ Member types π¦
value_typeβbool.typeβstd::integral_constant<bool, value>.
π Notes π
std::is_final is introduced by the resolution of LWG issue 2112.
A union can be declared final (and std::is_final will detect that), even though unions cannot be used as bases in any case. Thatβs right, bestie: final union? Iconic. π«Ά
Feature-test macro vibes:
__cpp_lib_is_finalβ value201402L, std(C++14), featurestd::is_final.
π Example π
// Run this code
#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()
{
}
πΈ See also πΈ
is_classβ checks if a type is a non-union class type(C++11)(class template).is_polymorphicβ checks if a type is a polymorphic class type(C++11)(class template).
π source/version/date: http://cppreference.com Β· 2024.06.10 Β· this manual page is std::is_final(3). mwah π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms