[Bug libstdc++/87106] Group move and destruction of the source, where possible, for speed

arthur.j.odwyer at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Oct 25 14:47:00 GMT 2018


Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> changed:

           What    |Removed                     |Added
                 CC|                            |arthur.j.odwyer at gmail dot com

--- Comment #4 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
Hi, I'm the author of P1144 "Object relocation in terms of move plus destroy".
Awesome work you've done here!
Have you seen my libc++ patch on the same topic as yours?


Specifically, the piece that I think is still missing from libstdc++'s
implementation (besides all the cool stuff that you'd get from the attribute)
is the trait `__has_trivial_construct<A, T, T&&>`. This trait allows you to
write your `__relocate_a_1` generically, instead of special-casing it for
`std::allocator<T>` in particular. (So for example it could also get picked up
for `std::pmr::polymorphic_allocator<T>`... even though I guess I didn't
implement that part for my libc++ patch, because I'm still waiting on
<memory_resource> to get merged.)

Here's my `__has_trivial_construct`:

And here's how std::vector uses it (which is significantly different from how
libstdc++'s std::vector is arranged, but I'm sure the trait would be the same):

I hope we get P1144 so that you don't have to waste time and brain cells
specializing `__is_trivially_relocatable<T>` for std::string and std::pair and
so on.

Complete tangent: I'm confused how vector.tcc is allowed to use "if constexpr"
in C++11 mode.

More information about the Gcc-bugs mailing list