Date: Wed, 2 Jul 2025 21:49:56 +0200
On 02/07/2025 19:25, Jonathan Wakely wrote:
>
>
> On Wed, 2 Jul 2025 at 17:06, David Brown via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> wrote:
>
>
> It turns out my suggestion was already covered by std::unique_ptr<T[]>.
> (I imagine that my idea could have lower overheads, but that's possibly
> just because I haven't thought through the details for more complex
> cases. And std::unique_ptr<T[]> has the big advantage of already
> existing - a few extra bytes overhead is unlikely to be significant in
> real code.)
>
>
> I don't think there's any overhead. sizeof(unique_ptr<T[]>) ==
> sizeof(T*) and it just stores a pointer to an array allocated with new[].
>
I tried it earlier today on godbolt.org, and got a size of 40 bytes for
the unique_ptr. Trying again now, I can't replicate the result - the
two sizes here are the same. I assume I did something weird earlier,
and the mistake was mine. That sounds more likely than there being such
a large overhead!
David
>
>
> On Wed, 2 Jul 2025 at 17:06, David Brown via Std-Proposals
> <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>>
> wrote:
>
>
> It turns out my suggestion was already covered by std::unique_ptr<T[]>.
> (I imagine that my idea could have lower overheads, but that's possibly
> just because I haven't thought through the details for more complex
> cases. And std::unique_ptr<T[]> has the big advantage of already
> existing - a few extra bytes overhead is unlikely to be significant in
> real code.)
>
>
> I don't think there's any overhead. sizeof(unique_ptr<T[]>) ==
> sizeof(T*) and it just stores a pointer to an array allocated with new[].
>
I tried it earlier today on godbolt.org, and got a size of 40 bytes for
the unique_ptr. Trying again now, I can't replicate the result - the
two sizes here are the same. I assume I did something weird earlier,
and the mistake was mine. That sounds more likely than there being such
a large overhead!
David
Received on 2025-07-02 19:50:00