Rob Stewart wrote:
...
That's error-prone. Why not provide (non-zero) capacity when using
make_shared(), and leave the non-make_shared() usage with a zero capacity?
That's not very convenient. Suppose you get a T* from some place and need to
pass shared_ptr to another that requires a known size. You know the
size, but you won't be able to pass it.
It's also error prone. If you have an interface that takes shared_ptr
and size_t, you can tell that the code is passing a size by mere visual
inspection. But if the function only takes a shared_ptr, and if
shared_ptr might or might not have a size, it's not immediately obvious
whether you are passing a size or not. Maybe you are, maybe you aren't;
we'll have to wait until runtime and see.
Finally, zero is technically a legitimate value for the size, signifying an
empty array, so overloading it to denote "unknown" may not be the best
option.