Date: Tue, 14 Apr 2026 10:08:35 -0400
On Tue, Apr 14, 2026 at 5:42 AM Marcin Jaczewski via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> wt., 14 kwi 2026 o 11:04 Yongwei Wu <wuyongwei_at_[hidden]> napisaĆ(a):
> >
> > I think it can work on pointers to (an array of) non-trivially-destructible objects. Maybe nobody finds a real usage scenario for this, thus no one has proposed it?
> >
>
> Real usage for me of this feature would be reduce size of
> `std::vector` as in this case you could avoid `capacity` duplication
> in vector.
> Of corse this will work only if allocator used `new[]` instead other
> manual handling, but even in this case allocator should perhaps know
> how big array is?
But the allocator's allocation and deletion functions explicitly take
a size. So the allocator explicitly does not need to know the size;
you have to provide it. And some allocators flat-out *cannot* know the
size; they just don't track that because the caller is supposed to.
<std-discussion_at_[hidden]> wrote:
>
> wt., 14 kwi 2026 o 11:04 Yongwei Wu <wuyongwei_at_[hidden]> napisaĆ(a):
> >
> > I think it can work on pointers to (an array of) non-trivially-destructible objects. Maybe nobody finds a real usage scenario for this, thus no one has proposed it?
> >
>
> Real usage for me of this feature would be reduce size of
> `std::vector` as in this case you could avoid `capacity` duplication
> in vector.
> Of corse this will work only if allocator used `new[]` instead other
> manual handling, but even in this case allocator should perhaps know
> how big array is?
But the allocator's allocation and deletion functions explicitly take
a size. So the allocator explicitly does not need to know the size;
you have to provide it. And some allocators flat-out *cannot* know the
size; they just don't track that because the caller is supposed to.
Received on 2026-04-14 14:08:49
