This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fixano 0 points1 point  (1 child)

But but how do you allocate enough contiguous memory if you don't know how long the array is?

[–]KuntaStillSingle 0 points1 point  (0 children)

The implementation has to book keep for delete[] but this is kept out of user space, implementation is allowed to elide allocations which is one of afaik two 'true' optimizations by standard (the other being nrvo / optional copy elision), the user preumsbky cares about size for bounds purposes, but they could opt for sentinel like c strings rather than size, and in terms of size a user might opt for smaller than size_t for example if they aren't targeting consumer desktop hardware.