Template Class ReservedSlot

Class Documentation

template<typename T>
class ReservedSlot

Handle for a reserved slot in the serializer stream.

When you need to write a value that depends on data written after it (e.g., list size before the list elements in lazy evaluation), use reserve() to create a slot, write the dependent data, then call write() on the slot to fill in the reserved space.

auto size_slot = serializer.reserve<size_t>();
size_t count = 0;
for (const auto& item : lazy_list) {
    serializer.add_value(item);
    count++;
}
size_slot.write(count);
Template Parameters:

T – The type of value reserved (must be a scalar type)

Public Functions

void write(const T &value)

Write the value to the reserved slot.

This writes the value at the reserved position without affecting the current write position. Can be called at any time after reserving.

Parameters:

value – The value to write