[utility.arg.requirements] (original) (raw)

16 Library introduction [library]

16.4 Library-wide requirements [requirements]

16.4.4 Requirements on types and expressions [utility.requirements]

16.4.4.2 Template argument requirements [utility.arg.requirements]

The template definitions in the C++ standard library refer to various named requirements whose details are set out in Tables 2835.

In these tables,

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.

Table 28Cpp17EqualityComparable requirements [tab:cpp17.equalitycomparable]

decltype(a == b) models boolean-testable == is an equivalence relation, that is, it has the following properties:If a == b and b == c, then a == c.

Table 30Cpp17DefaultConstructible requirements [tab:cpp17.defaultconstructible]

object t is default-initialized
object u is value-initialized or aggregate-initialized
an object of type T is value-initialized or aggregate-initialized

Table 31Cpp17MoveConstructible requirements [tab:cpp17.moveconstructible]

u is equivalent to the value of rv before the construction
T(rv) is equivalent to the value of rv before the construction
rv's state is unspecified[Note 1: 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 32Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible) [tab:cpp17.copyconstructible]

the value of v is unchanged and is equivalent to u
the value of v is unchanged and is equivalent to T(v)

Table 33Cpp17MoveAssignable requirements [tab:cpp17.moveassignable]

🔗Expression Return type Return value Post-condition
🔗t = rv T& t If t and rv do not refer to the same object,t is equivalent to the value of rv before the assignment
🔗rv's state is unspecified. [Note 2: rv must still meet the requirements of the library component that is using it, whether or not t and rv refer to the same object. The operations listed in those requirements must work as specified whether rv has been moved from or not. — _end note_]

Table 35Cpp17Destructible requirements [tab:cpp17.destructible]

All resources owned by u are reclaimed, no exception is propagated.
[Note 3: Array types and non-object types are not Cpp17Destructible. — _end note_]