Is empty struct defined by C++ standard?

There is a section to add this kind of construct as part of the Variant proposal (n4542).

After being voted on,

What do we want to call the “empty_t” stand-in type?
empty_t 4
empty 4
one_t 1
blank 6
blank_t 7
monostate 7

Runoff:
blank* 3
monostate 8

the agreed upon name would be: std::monostate.


It would be defined the following way:

// 2.?, Explicitly default-constructed alternative
struct monostate {};
bool operator<(const monostate&, const monostate&) constexpr
{ return false; }
bool operator>(const monostate&, const monostate&) constexpr
{ return false; }
bool operator<=(const monostate&, const monostate&) constexpr
{ return true; }
bool operator>=(const monostate&, const monostate&) constexpr
{ return true; }
bool operator==(const monostate&, const monostate&) constexpr
{ return true; }
bool operator!=(const monostate&, const monostate&) constexpr
{ return false; }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)