[Bug libstdc++/86127] STL containers do not satisfy container.requirements.general clause 8
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 13 17:49:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86127
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Scott Constable from comment #7)
> (In reply to Jonathan Wakely from comment #1)
> > The allocator requirements say that move construction must be equivalent to
> > copy construction, and allocators should be cheap to copy anyway. I don't
> > consider this a bug.
>
> To be nitpicky, it looks like this equivalence requirement was introduced
> recently in the C++20 draft. I'm compiling using C++14.
It's a defect report, so applies to previous standards.
https://wg21.link/lwg2593
Applying that change selectively would be madness.
> I agree that allocators should be cheap to copy, but as a general principle
> I think that all objects should be copied only when necessary. This is the
> behavior I have observed in STL containers in libc++, as shown in my example
> above. It just makes sense to me that when an STL container is moved, its
> allocator should be moved, and no copying should be performed.
And that's exactly what libstdc++ does. Your test fails to distinguish between
copies/moves performed during move construction and other operations.
More information about the Gcc-bugs
mailing list