bitsery icon indicating copy to clipboard operation
bitsery copied to clipboard

Is there a way to detect (on runtime or compiletime), if the given size is too smal to fit the value?

Open Febbe opened this issue 3 years ago • 3 comments

Febbe avatar Aug 10 '21 13:08 Febbe

I don't understand the question... .... if the given size (size of what?) is too small to fit the value (what value?)?

fraillt avatar Aug 25 '21 19:08 fraillt

I meant, if there are any debug capabilities to check, if the specified size for an exported value is too small to fit the actual/original value?

Febbe avatar Aug 26 '21 20:08 Febbe

If I understand you correctly, you are looking for MeasureSize adapter. It works exactly the same as the output adapter. You can use it like this:

#include <bitsery/adapter/measure_size.h>
...
auto writtenSize = bitsery::quickSerialization(bitsery::MeasureSize{}, data);

fraillt avatar Aug 26 '21 21:08 fraillt