[nullablepointer.requirements] (original) (raw)

16 Library introduction [library]

16.5 Library-wide requirements [requirements]

16.5.3 Requirements on types and expressions [utility.requirements]

16.5.3.3 Cpp17NullablePointer requirements [nullablepointer.requirements]

A Cpp17NullablePointer type is a pointer-like type that supports null values.

A type P meets the Cpp17NullablePointer requirements if:

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 value.

[ Note

:

Operations involving indeterminate values may cause undefined behavior.

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 33, 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 33: 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 contextually convertible to bool !(a == b)
a == np contextually convertible to bool a == P()
np == a
a != np contextually convertible to bool !(a == np)
np != a