What should I call this unique-pointer-with-size structure?

33 Views Asked by At

I'm annoyed by how C++' standard library only offers some functionality via pointers rather than structures which keep both an address and a size. Specifically, suppose I want something like a unique_ptr<T[]>, but which keeps the associated length/size.

This is not that hard to implement (especially if I avoid the need to distinguish between array and non-array template parameters like in make_unique()); but - what should I call this unique-ptr-with-size ? I was thinking of unique_span or unique_region... or maybe there is some other name that's more appropriate, or more popular, for this structure?

Note: It doesn't seem to be any of the vector-like constructs listed in this table.

1

There are 1 best solutions below

0
relgukxilef On

To my knowledge, there is no std or boost container that quite fits this purpose.

I recommend calling it unique_span, as it is practically a std::span, with the added property of owning the data.