C++ concepts: NullablePointer (since C++11) - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# C++ concepts: NullablePointer (since C++11)

From cppreference.com
< cpp‎ | concept

Specifies that the type is an pointer-like object which can be compared to std::nullptr_t objects.

### [edit] Requirements

The type must meet all of the following concept requirements:

- `EqualityComparable`
- `DefaultConstructible`
- `CopyConstructible`
- `CopyAssignable`
- `Destructible`

In addition, a value-initialized object of the type must produce a null value of that type. This null value shall only be equivalent to itself. Default initialization of the type may have an indeterminate value.

An object of the type must be contextually convertible to bool. The effect of this conversion returns false if the value is equivalent to its null value and true otherwise.

None of the operations that this type performs may throw exceptions.

The type must satisfy the following additional expressions, given two values `p` and `q` that are of the type, and that `np` is a value of std::nullptr_t type (possibly const qualified):

Expression | Effects
Type p(np); Type p = np; | Afterwards, `p` is equivalent to nullptr
Type(np) | a temporary object that is equivalent to nullptr
p = np | Must return a `Type&`, and afterwards, `p` is equivalent to nullptr
p != q | Must return a value that is contextually convertible to bool. The effect is `!(p == q)`
p == np np == p | Must return a value that is contextually convertible to bool. The effect is `(p == Type())`
p != np np != p | Must return a value that is contextually convertible to bool. The effect is `!(p == np)`

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/concept/NullablePointer&oldid=49414"