std::experi...::nullopt_t(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

Hey bestie! πŸ’– This is the std::experi...::nullopt_t(3) page from the C++ Standard Libary manual β€” yes, the header repeats std::experi...::nullopt_t(3), and we are not doing that twice, periodt. πŸŽ€

🌸 NAME 🌸

std::experi...::nullopt_t β€” literally std::experi...::nullopt_t. That’s the whole name, no cap. ✨

✨ Synopsis ✨

Okay so here’s where it lives and what it looks like:

Defined in header <experimental/optional>
struct nullopt_t;                          (library fundamentals TS)

std::experimental::nullopt_t is an empty class type used to indicate optional type with uninitialized state. In particular, std::experimental::optional has a constructor with nullopt_t as a single argument, which creates an optional that does not contain a value. 🫢

std::experimental::nullopt_t must be a LiteralType and cannot have a default constructor. πŸ‘‘

It must have a constexpr constructor that takes some implementation-defined literal type. πŸ’…

πŸ¦‹ Notes πŸ¦‹

nullopt_t is not DefaultConstructible to support both op = {}; and op = nullopt; as the syntax for disengaging an optional object. That’s the whole vibe β€” it’s giving very deliberate design choice. 😭

A possible implementation of this class is:

struct nullopt_t
{
    constexpr nullopt_t(int) {}
};

πŸ’œ See also πŸ’œ

  • nullopt β€” an object of type nullopt_t (C++17) (constant)

πŸ‘‘ Category πŸ‘‘

  • Noindexed pages

Okay that’s the page, bestie! Source/version/date sign-off: http://cppreference.com Β· 2024.06.10 Β· std::experi...::nullopt_t(3). Bye bestie, go disengage an optional responsibly πŸŒˆπŸ’–

πŸ“¦ where this page comes from