Subject: Re: Moved-from containers and moved-from allocators
From: Tony V E (tvaneerd_at_[hidden])
Date: 2019-06-03 15:38:16
On Mon, Jun 3, 2019 at 10:52 AM Martin Sjogren via Std-Discussion <
> As a result of https://cplusplus.github.io/LWG/issue2593 after
> move-constructing an allocator x from an allocator y the standard will
> require that x and y compare equal. My understanding is that this is
> because moving a container also moves the allocator, but (some?) moved-from
> containers still need a functioning allocator.
> But doesn't this effectively mean that moving from an allocator is
> impossible and in the vast majority of cases moving needs to be implemented
> as copying?
> Wouldn't it make more sense for the containers that need an allocator in
> their moved-from state to copy their allocator instead of moving?
All standard containers that have an allocator need an allocator in their
moved-from state. A moved-from container is still a functioning container.
> As-is, I feel like there's a big trap when implementing an allocator that
> you have to take very special care with the move constructor (or in
> practice just not have one)
> Would there be any interest in an issue report for this?
> Std-Discussion mailing list
-- Be seeing you, Tony
STD-DISCUSSION list run by email@example.com
Older Archives on Google Groups