The template definitions in the C++ standard library
refer to various named requirements whose details are set out in
tables [equalitycomparable]–[destructible].
In these tables, T is an object or reference type to be
supplied by a C++ program instantiating a template;
a,
b, and
c are values of type (possibly const) T;
s and t are modifiable lvalues of type T;
u denotes an identifier;
rv is an rvalue of type T;
and v is an lvalue of type (possibly const) T or an rvalue of
type const T.
In general, a default constructor is not required. Certain container class
member function signatures specify T() as a default argument.
T() shall be a well-defined expression ([dcl.init]) if one of those
signatures is called using the default argument ([dcl.fct.default]).
Table
17 —
EqualityComparable requirements
Expression | Return type | Requirement |
a == b |
convertible to bool |
== is an equivalence relation,
that is, it has the following properties:
|
Table
18 —
LessThanComparable requirements
Expression | Return type | Requirement |
a < b |
convertible to bool |
< is a strict weak ordering relation ([alg.sorting]) |
Table
19 —
DefaultConstructible requirements
Expression | Post-condition |
T t; | object t is default-initialized |
T u{}; | object u is value-initialized |
T() | a temporary object of type T is value-initialized |
T{} | |
Table
20 —
MoveConstructible requirements
Expression | Post-condition |
T u = rv; | u is equivalent to the value of rv before the construction |
T(rv) |
T(rv) is equivalent to the value of rv before the construction |
rv's state is unspecified
[ Note: rv must still meet the requirements of the library
component that is using it. The operations listed in those requirements must
work as specified whether rv has been moved from or not. — end note ] |
Table
21 —
CopyConstructible requirements (in addition to
MoveConstructible)
Expression | Post-condition |
T u = v; | the value of v is unchanged and is equivalent to u |
T(v) |
the value of v is unchanged and is equivalent to T(v) |
Table
22 —
MoveAssignable requirements
Expression | Return type | Return value | Post-condition |
t = rv | T& | t | t is equivalent
to the value of rv before the assignment |
rv's state is unspecified.
[ Note: rv must still meet the requirements of the library
component that is using it. The operations listed in those requirements must
work as specified whether rv has been moved from or not. — end note ] |
Table
23 —
CopyAssignable requirements (in addition to
MoveAssignable)
Expression | Return type | Return value | Post-condition |
t = v | T& | t | t is equivalent to v, the value of v is unchanged |
Table
24 —
Destructible requirements
Expression | Post-condition |
u.~T() | All resources owned by u are reclaimed, no exception is propagated. |