-
Notifications
You must be signed in to change notification settings - Fork 0
API muesli monostate_codec
Felix Jones edited this page Jan 15, 2026
·
1 revision
Defined in header <muesli/monostate_codec>
inline constexpr constant_codec<std::monostate> monostate_codec{};Codec for std::monostate (empty variant state).
Encodes and decodes std::monostate, the empty state type used in std::variant. Useful as a placeholder codec when representing absence of data, particularly in optional or nullable contexts where no actual value needs to be encoded.
// Used internally by optional_codec to represent absent values
auto opt_codec = muesli::int32_codec.optional();
std::optional<int32_t> absent = std::nullopt;
auto encoded = opt_codec.encode(absent); // Uses monostate_codec for the empty variant