During discussions it became apparent that member function max_size on types modelling DynamicBufferParam (so this probably also applies to DynamicBuffer) has different meaning than the member function of the same name and signature in STL containers.
In STL containers max_size() means (https://en.cppreference.com/cpp/container/vector/max_size):
The maximum number of elements the container of this type is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container.
In Capy, DynamicBuffer defines max_capacity vaguely:
Maximum allowed size. Attempts to grow beyond this throw or fail.
But some algorithms (read_until) inconsistently use it for controlling the number of bytes to be read from the stream, which follows the pattern from ASIO: https://www.boost.org/doc/libs/latest/doc/html/boost_asio/reference/read/overload6.html.
Document clearly what the contract of this operation in DynamicBufferParam is. (It could be an additional semantic requirement relative to DynamicBuffer). If the goal is to control the logic of stream algorithms, change the name of the function so that does not incorrectly imply the semantics of max_size from STL containers.
During discussions it became apparent that member function
max_sizeon types modellingDynamicBufferParam(so this probably also applies toDynamicBuffer) has different meaning than the member function of the same name and signature in STL containers.In STL containers
max_size()means (https://en.cppreference.com/cpp/container/vector/max_size):In Capy,
DynamicBufferdefinesmax_capacityvaguely:But some algorithms (
read_until) inconsistently use it for controlling the number of bytes to be read from the stream, which follows the pattern from ASIO: https://www.boost.org/doc/libs/latest/doc/html/boost_asio/reference/read/overload6.html.Document clearly what the contract of this operation in
DynamicBufferParamis. (It could be an additional semantic requirement relative toDynamicBuffer). If the goal is to control the logic of stream algorithms, change the name of the function so that does not incorrectly imply the semantics ofmax_sizefrom STL containers.