-
Notifications
You must be signed in to change notification settings - Fork 0
API muesli identity_codec
Felix Jones edited this page Jan 15, 2026
·
1 revision
Defined in header <muesli/identity_codec>
template<T>
struct identity_codec : fluent::optionable<identity_codec<T>>,
fluent::constrainable<identity_codec<T>>,
fluent::projectable<identity_codec<T>>,
fluent::transformable<identity_codec<T>>,
fluent::nullableable<identity_codec<T>>,
fluent::constructable<identity_codec<T>>The simplest codec - passes values through unchanged
The identity_codec is a no-op codec that encodes and decodes by simply returning the value as-is. This is useful as a building block for more complex codecs and as a codec for primitive types.
Template parameters:
- T: The type to encode/decode
Example usage:
auto codec = muesli::identity_codec<int>();
int value = 54;
auto encoded = codec.encode(value); // Returns 54
auto decoded = codec.decode(encoded); // Returns 54value_type
using value_type = TThe type that this codec encodes and decodes
Returns the value unchanged (rvalue overload)
static constexpr value_type&& decode(value_type&& value) noexcept
static constexpr const value_type& decode(const value_type& value) noexceptReturns the value unchanged (rvalue overload)
static constexpr value_type&& encode(value_type&& value) noexcept
static constexpr const value_type& encode(const value_type& value) noexceptReturns itself as the next codec (identity operation)
constexpr const identity_codec& next_codec() const noexceptThis codec has zero overhead - encode and decode are inline no-ops.
auto codec = muesli::identity_codec<int>();
int value = 54;
auto encoded = codec.encode(value); // Returns 54
auto decoded = codec.decode(encoded); // Returns 54using value_type = T; /** @brief Returns itself as the next codec (identity operation) */ constexpr const identity_codec& next_codec() const noexceptThe type that this codec encodes and decodes
static constexpr value_type&& encode(value_type&& value) noexceptReturns the value unchanged (rvalue overload)
static constexpr value_type&& decode(value_type&& value) noexceptReturns the value unchanged (rvalue overload)