-
Notifications
You must be signed in to change notification settings - Fork 0
API muesli range_codec
Felix Jones edited this page Jan 15, 2026
·
1 revision
Defined in header <muesli/range_codec>
struct range_codec : fluent::optionable<range_codec<ElementCodec>>,
fluent::constrainable<range_codec<ElementCodec>>,
fluent::transformable<range_codec<ElementCodec>>,
fluent::projectable<range_codec<ElementCodec>>,
fluent::constructable<range_codec<ElementCodec>>,
fluent::nullableable<range_codec<ElementCodec>>Codec for range-based iteration over encoded sequences.
The range_codec transforms a codec for individual elements into a codec for range_holder, enabling lazy iteration over encoded element sequences. Used internally by vector_codec and array_codec for element iteration.
| Parameter | Description |
|---|---|
ElementCodec |
Codec for individual range elements |
value_type
using value_type = range_holder<typename ElementCodec::value_type>Value type is a range holder of element values
next_codec_type
using next_codec_type = std::decay_t<decltype(std::declval<ElementCodec>().next_codec())>Next codec type in the encoding chain
encoded_type
using encoded_type = range_holder<typename next_codec_type::value_type>Encoded type is a range holder of encoded elements
Constructs a range_codec with the given element codec
explicit constexpr range_codec(const ElementCodec& codec) noexcept : element_codec(codec)auto codec = range_codec(int32_codec);
range_holder<int32_t> rh = {...};
auto encoded = codec.encode(rh);- Related codecs:
array_codec,vector_codec
using value_type = range_holder<typename ElementCodec::value_type>; /** @brief Next codec type in the encoding chain */ using next_codec_type = std::decay_t<decltype(std::declval<ElementCodec>().next_codec())>; /** @brief Encoded type is a range holder of encoded elements */ using encoded_type = range_holder<typename next_codec_type::value_type>; /** @brief Codec for individual range elements */ ElementCodec element_codec; /** @brief Constructs a range_codec with the given element codec */ explicit constexpr range_codec(const ElementCodec& codec) noexcept : element_codec(codec)Value type is a range holder of element values
constexpr auto next_codec() const noexceptReturns a range_codec wrapping the next codec in the chain
encoded_type encode(auto&& value) constEncodes a range by lazily encoding each element
template<typename E> value_type decode(E&& encoded) constDecodes a range by lazily decoding each encoded element