[nullablepointer.requirements]

# 16 Library introduction [[library]](./#library)

## 16.4 Library-wide requirements [[requirements]](requirements#nullablepointer.requirements)

### 16.4.4 Requirements on types and expressions [[utility.requirements]](utility.requirements#nullablepointer.requirements)

#### 16.4.4.4 *Cpp17NullablePointer* requirements [nullablepointer.requirements]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2018)

A *Cpp17NullablePointer* type is a pointer-like type that supports null values[.](#1.sentence-1)

A type P meets the *Cpp17NullablePointer* requirements if

- [(1.1)](#1.1)

P meets the [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), *Cpp17CopyAssignable*,[*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3 Swappable requirements [swappable.requirements]"), and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements,

- [(1.2)](#1.2)

the expressions shown in Table [36](#tab:cpp17.nullablepointer "Table 36: Cpp17NullablePointer requirements") are
valid and have the indicated semantics, and

- [(1.3)](#1.3)

P meets all the other requirements of this subclause[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2032)

A value-initialized object of type P produces the null value of the type[.](#2.sentence-1)

The null value shall be equivalent only to itself[.](#2.sentence-2)

A default-initialized object
of type P may have an indeterminate or erroneous value[.](#2.sentence-3)

[*Note [1](#note-1)*:

Operations involving indeterminate values can cause undefined behavior, and
operations involving erroneous values can cause erroneous behavior ([[basic.indet]](basic.indet "6.8.5 Indeterminate and erroneous values"))[.](#2.sentence-4)

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2041)

An object p of type P can be[contextually converted to bool](conv#def:conversion,contextual_to_bool "7.3 Standard conversions [conv]")[.](#3.sentence-1)

The effect shall be as if p != nullptr had been evaluated in place of p[.](#3.sentence-2)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2047)

No operation which is part of the *Cpp17NullablePointer* requirements shall exit
via an exception[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/lib-intro.tex#L2051)

In Table [36](#tab:cpp17.nullablepointer "Table 36: Cpp17NullablePointer requirements"), u denotes an identifier, t denotes a non-const lvalue of type P, a and b denote values of type (possibly const) P, and np denotes
a value of type (possibly const) std​::​nullptr_t[.](#5.sentence-1)

Table [36](#tab:cpp17.nullablepointer) — *Cpp17NullablePointer* requirements [[tab:cpp17.nullablepointer]](./tab:cpp17.nullablepointer)  

| [ð](#tab:cpp17.nullablepointer-row-1)<br>**Expression** | **Return type** | **Operational semantics** |
| --- | --- | --- |
| [ð](#tab:cpp17.nullablepointer-row-2)<br>P u(np); |  | *Postconditions*: u == nullptr |
| [ð](#tab:cpp17.nullablepointer-row-3)<br>P u = np; |  |  |
| [ð](#tab:cpp17.nullablepointer-row-4)<br>P(np) |  | *Postconditions*: P(np) == nullptr |
| [ð](#tab:cpp17.nullablepointer-row-5)<br>t = np | P& | *Postconditions*: t == nullptr |
| [ð](#tab:cpp17.nullablepointer-row-6)<br>a != b | decltype(a != b) models [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]") | !(a == b) |
| [ð](#tab:cpp17.nullablepointer-row-7)<br>a == np | decltype(a == np) and decltype(np == a) each model [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]") | a == P() |
| [ð](#tab:cpp17.nullablepointer-row-8)<br>np == a |  |  |
| [ð](#tab:cpp17.nullablepointer-row-9)<br>a != np | decltype(a != np) and decltype(np != a) each model [*boolean-testable*](concept.booleantestable#concept:boolean-testable "18.5.2 Boolean testability [concept.booleantestable]") | !(a == np) |
| [ð](#tab:cpp17.nullablepointer-row-10)<br>np != a |  |  |
