std::monostate (3) - Linux Manuals
std::monostate: std::monostate
NAME
std::monostate - std::monostate
Synopsis
Defined in header <variant>
struct monostate { }; (since C++17)
Unit type intended for use as a well-behaved empty alternative in std::variant. In particular, a variant of non-default-constructible types may list std::monostate as its first alternative: this makes the variant itself default-constructible.
Member functions
constructor trivial implicit default/copy/move constructor
(implicitly declared)
destructor trivial implicit destructor
(implicitly declared)
operator= trivial implicit copy/move assignment
(implicitly declared)
Non-member functions
constexpr bool operator<(monostate, monostate) noexcept { return false; }
constexpr bool operator>(monostate, monostate) noexcept { return false; }
constexpr bool operator<=(monostate, monostate) noexcept { return true; }
constexpr bool operator>=(monostate, monostate) noexcept { return true; }
constexpr bool operator==(monostate, monostate) noexcept { return true; }
constexpr bool operator!=(monostate, monostate) noexcept { return false; }
All instances of std::monostate compare equal.
Helper classes
std::hash<std::monostate>
template <> struct std::hash<monostate>;
Specializes the std::hash algorithm for std::monostate.
Example
// Run this code
Output:
See also
constructor (public member function)