C++ Logo

std-discussion

Advanced search

Moved-from containers and moved-from allocators

From: Martin Sjogren <msjogren_at_[hidden]>
Date: Mon, 3 Jun 2019 16:22:14 +0200
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?

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?

Received on 2019-06-03 09:54:13