Mere moments ago, quoth I:
On 25/01/2020 01:21, Glen Fernandes wrote:
Heap storage, fixed size at runtime: allocate_unique
(alloc, size, ...) Gives users everything they need for buffers. (They don't need a Container that is copyable).
Not quite. These keep the storage pointer and the storage size separately, so you still need a wrapper type (such as the Asio buffer types), or to keep passing them around separately (which is error-prone) or to make assumptions instead of passing it around (which is very error-prone).
C++20 introduces std::span, which is a good way of passing around a pointer and size together -- but it's non-owning, so still isn't a solution for the above.
To clarify: the Asio buffer types are also non-owning. The need for an owning wrapper type is presumably what: On 24/01/2020 21:44, Alexander Grund wrote:
- Heap storage, fixed size at runtime: dynamic_array
was referring to (a type that contains a unique_ptr