[cfe-dev] [libc++]x=move(x) behavior

Howard Hinnant via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 2 07:19:12 PDT 2015


On Oct 2, 2015, at 6:24 AM, b17 c0de <b17c0de at gmail.com> wrote:
> 
> Howard,
> Whats preventing you from making that change. It looks better anyway. :)
> 

I haven’t been an active maintainer of libc++ for over 18 months.  My day job is elsewhere.  So I haven’t fully vetted my suggested change (run tests, given it more than 10min thought, etc., etc).  Others are filling this valuable role, and doing a great job at it.

Eric Fiselier suggested that perhaps it would be better to just swap the capacity to the rhs instead of delete it.  That is also a very good suggestion (only because string holds only pods — we should not do this for vector).

In any event, adding another branch to make self-move-assignment a no-op doesn’t sound like a good direction to me.  The whole point of move assignment is to get performance down to where you’re counting branches and cycles.  Why penalize everyone’s code because a few use std::move once too often in their code?

I know it can happen accidentally.  Speaking for my own code, I want to find those accidents and remove them, as opposed to render the accidents invisible.  Others have other positions on this issue and I respect that.  This is my position.

Howard




More information about the cfe-dev mailing list