Specifies that a class is replaceable (replaceable_if_eligible), trivially relocatable (trivially_relocatable_if_eligible), or that a class cannot be derived from (final).
[edit] SyntaxClass property specifiers appear at the beginning of the class definition, immediately after the name of the class, and cannot appear in a class declaration.
class-key attr (optional) class-head-name class-prop-specifier-seq (optional) base-clause (optional)Before (C++26), there was the class-virt-specifier (optional) in place of class-prop-specifier-seq (optional), which only allowed the final for final
specifier (since C++11).
final, replaceable_if_eligible and trivially_relocatable_if_eligible are identifiers with a special meaning when used in a class head. In other contexts, it is not reserved and may be used to name objects and functions.
[edit] final specifierfinal specifies that this class may not appear in the base-specifier-list of another class definition (in other words, cannot be derived from). The program is ill-formed otherwise (a compile-time error is generated). final can also be used with a union definition, in which case it has no effect (other than on the outcome of std::is_final)(since C++14), since unions cannot be derived from.
[edit] replaceable_if_eligible specifierreplaceable_if_eligible specifies that this class is replaceable if it is eligible for replacement .
[edit] trivially_relocatable_if_eligible specifiertrivially_relocatable_if_eligible specifies that this class is trivially relocatable if it is eligible for trivial relocation .
[edit] ReplaceabilityA class C
is replaceable if it is eligible for replacement and either:
union
with no user-declared special member functionsA class C
is eligible for replacement unless either:
C
from an xvalue of type C
C
from an xvalue of type C
A class is trivially relocatable if it is eligible for trivial relocation and either:
union
with no user-declared special member functionsA class is eligible for trivial relocation unless it has either:
except that it is implementation-defined whether an otherwise-eligible union
having one or more subobjects of polymorphic class type is eligible for trivial relocation .
A class C
is default movable if all following conditions are met:
C
from an xvalue of type C
selects a constructor that is a direct member of C
and is neither user-provided nor deletedC
from an xvalue of type C
selects an assignment operator function that is a direct member of C
and is neither user-provided nor deletedC
has a destructor that is neither user-provided nor deleted.final, replaceable_if_eligible, trivially_relocatable_if_eligible.
[edit] Noteunion
s with no user-declared special member functions and default movable classes are both replaceable and trivially relocatable , even when defined without class property specifiers.struct final; // OK; declares a class named 'final', // does not use class property specifiers. struct IF final; // Ill-formed: class property specifiers // cannot appear at function declaration. struct F final {}; // OK; specifier marks class F as non-derivable. struct D: F {}; // Ill-formed: class F cannot be derived from. // OK; specifier marks class R as ð³ð¦ð±ðð¢ð¤ð¦ð¢ð£ðð¦ if eligible. struct R replaceable_if_eligible {}; // OK; specifier marks class T as ðµð³ðªð·ðªð¢ðððº ð³ð¦ðð°ð¤ð¢ðµð¢ð£ðð¦ if eligible. struct T trivially_relocatable_if_eligible {}; // OK; a class can be marked with multiple class property specifiers. struct FRT final replaceable_if_eligible trivially_relocatable_if_eligible {}; // Ill-formed: each class property specifier can appear at most once. struct FRF final replaceable_if_eligible final {}; int main() {}[edit] References
final
specifier (C++11) declares that a method cannot be overridden or a class be derived from[edit] checks if a type is a final class type
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4