[nullablepointer.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.4 Cpp17NullablePointer requirements [nullablepointer.requirements]
A Cpp17NullablePointer type is a pointer-like type that supports null values.
A value-initialized object of type P produces the null value of the type.
The null value shall be equivalent only to itself.
A default-initialized object of type P may have an indeterminate or erroneous value.
[Note 1:
Operations involving indeterminate values can cause undefined behavior, and operations involving erroneous values can cause erroneous behavior ([basic.indet]).
β _end note_]
The effect shall be as if p != nullptrhad been evaluated in place of p.
No operation which is part of the Cpp17NullablePointer requirements shall exit via an exception.
In Table 36, u denotes an identifier, tdenotes a non-const lvalue of type P, a and bdenote values of type (possibly const) P, and np denotes a value of type (possibly const) stdβ::βnullptr_t.
Table 36 β Cpp17NullablePointer requirements [tab:cpp17.nullablepointer]
πExpression | Return type | Operational semantics |
---|---|---|
πP u(np); | Postconditions: u == nullptr | |
πP u = np; | ||
πP(np) | Postconditions: P(np) == nullptr | |
πt = np | P& | Postconditions: t == nullptr |
πa != b | decltype(a != b) models boolean-testable | !(a == b) |
πa == np | decltype(a == np) and decltype(np == a) each model boolean-testable | a == P() |
πnp == a | ||
πa != np | decltype(a != np) and decltype(np != a) each model boolean-testable | !(a == np) |
πnp != a |