|
SofaBuffers C++ 0.12.0
Pure-C++20 SofaBuffers — API Documentation
|
Give dst room for want, if it is a destination the caller has to size.
More...
#include <sofab.hpp>
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.
| dst | Destination. |
| want | Room 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.