Skip to content

API muesli fluent constructable

Felix Jones edited this page Jan 15, 2026 · 1 revision

muesli/fluent/constructable

Defined in header <muesli/fluent/constructable>

apply_codec

template<ValueType>
struct apply_codec

Forward declaration of apply_codec

Member Functions

apply

Creates an apply_codec targeting the specified type

Wraps this codec with type transformation to encode/decode a different target type. The apply_codec will call user-provided constructor functions or use default construction when transitioning between types.

template<typename ValueType> constexpr auto apply() const noexcept

Returns: An apply_codec that constructs ValueType from this codec

Example:

struct Point { double x, y; };
auto coords = tuple_codec(double_codec, double_codec);
auto point_codec = coords.apply<Point>();

constructable

template<Derived>
struct constructable

Mixin providing .apply() to construct values of type T

This mixin provides the .apply() method which wraps the current codec in an apply_codec to encode/decode a different type than the codec's native value_type. Useful for adapting codecs to custom types.

Member Functions

apply

Creates an apply_codec targeting the specified type

Wraps this codec with type transformation to encode/decode a different target type. The apply_codec will call user-provided constructor functions or use default construction when transitioning between types.

template<typename ValueType> constexpr auto apply() const noexcept

Returns: An apply_codec that constructs ValueType from this codec

Example:

struct Point { double x, y; };
auto coords = tuple_codec(double_codec, double_codec);
auto point_codec = coords.apply<Point>();

Related


apply

template<typename ValueType> constexpr auto apply() const noexcept

Creates an apply_codec targeting the specified type

Wraps this codec with type transformation to encode/decode a different target type. The apply_codec will call user-provided constructor functions or use default construction when transitioning between types.

Template Parameters

Parameter Description
ValueType The target type to encode/decode

Returns: An apply_codec that constructs ValueType from this codec

Example

struct Point { double x, y; };
auto coords = tuple_codec(double_codec, double_codec);
auto point_codec = coords.apply<Point>();

Clone this wiki locally