# std::nullopt_t

> C++ Atlas: `cppatlas.com/w/cpp/utility/optional/nullopt_t` | Source: https://en.cppreference.com/w/cpp/utility/optional/nullopt_t | Domain: Utility | Standards: C++17

std::nullopt_t is an empty class type used to indicate that an std::optional does not contain a value.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <optional>
struct nullopt_t; // (since C++17)
```

`std::nullopt_t` is an empty class type used to indicate that an `std::optional` does not contain a value.

`std::nullopt_t` is a non-aggregate *LiteralType* that has no default constructor, no initializer-list constructor, but does have a `constexpr` constructor that takes an implementation-defined literal type.

### Notes

The constraints on `nullopt_t`'s constructors exist to support both `op = {};` and `op = nullopt;` as the syntax for disengaging an optional object.

A possible implementation of this class is

```cpp
struct nullopt_t {
    constexpr explicit nullopt_t(int) {}
};
```

### See also

- [`nullopt`](https://en.cppreference.com/w/cpp/utility/optional/nullopt) (C++17): an object of type `nullopt_t` (constant)

---
Attribution: content from https://en.cppreference.com/w/cpp/utility/optional/nullopt_t (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.