SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
Loading...
Searching...
No Matches
sofab::detail::sizable Concept Reference

Give dst room for want, if it is a destination the caller has to size. More...

#include <sofab.hpp>

Concept definition

template<typename D>
concept sofab::detail::sizable = requires(D &d) { d.resize(size_t{}); } && !requires { D::capacity(); }
Give dst room for want, if it is a destination the caller has to size.
Definition sofab.hpp:6373

Detailed Description

Give dst room for want, if it is a destination the caller has to size.

Helper layer: this is the allocator call §6.6 moved out of the codec, and it is here rather than there because the storage belongs to whoever called this. A destination with static room (T::capacity()) needs nothing — it already holds what it can ever hold — and one of fixed extent with no resize cannot be sized at all.

Only ever grows: a destination the caller deliberately sized larger keeps its room, and the decoded length is published by sofab::detail::destSetLen when the value is in.

Parameters
dstDestination.
wantRoom the announced value needs, already clamped by the caller to what the bytes in hand could fill.

Is D a destination the caller has to size?

True only for heap-growable storage: it can be resized and publishes no static capacity. A sofab::FixedString / sofab::FixedBytes / sofab::InlineVector already holds everything it can hold, and a std::array or a bound span cannot be sized at all — for those the whole helper below compiles away and generated code pays nothing for calling it.

Definition at line 6373 of file sofab.hpp.