[cfe-dev] [PATCH] Add APValue::swap

Benjamin Kramer benny.kra at googlemail.com
Thu Mar 8 15:05:08 PST 2012


On 08.03.2012, at 23:54, David Blaikie wrote:

> On Thu, Mar 8, 2012 at 2:46 PM, Chris Lattner <clattner at apple.com> wrote:
>> 
>> On Mar 8, 2012, at 10:45 AM, Howard Hinnant wrote:
>> 
>>> On Mar 8, 2012, at 1:39 PM, Daniel Dunbar wrote:
>>> 
>>>> I wanted to make the copy assignment operator private to encourage
>>>> callers to see if they could use swap instead.
>>>> 
>>>> My motivation here seems confused though, per subsequent discussion.
>>> 
>>> I think you're just ahead of your time.  Sounds like you're trying to encourage C++11 move assignment. :-) (which I think would be a very good idea, but requires commitment to using C++11)
>> 
>> I think that it would be completely reasonable (maybe even, "insanely great"?) to put move constructors and assignment operators into llvm & clang if they help performance and are *optional* and ifdef'd on compiler support.
>> 
>> That would just mean that people with c++'11 compilers can get better build times, but that we remain compatible with older compilers.
> 
> Usually we have to/have worked around the cases (you know, the usual
> "don't return big things by value") - the most common things that
> would benefit would be stuff that this already happens for (eg:
> std::string). Anyone know of good candidates that we wouldn't
> reasonably fix for the 98 case by removing the copies?

We have some cases of SmallVectors and DenseMaps of objects with non-trivial copy ctors. It would spare us a few deep copies if the container would move them when it reallocates.

Not sure if it's worth introducing a ton of #ifdef'd code. Sounds like a maintenance nightmare to me.

- Ben

> 
> - David
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list