[PATCH] Exploit move semantics in std::accumulate.

Paolo Carlini paolo.carlini@oracle.com
Tue Jan 11 13:09:00 GMT 2011


... I'm thinking:
> On Tue, 11 Jan 2011, Paolo Carlini wrote:
>
>> ... for concreteness, this is what I actually tested.
>
> Why use x=move(x)+y and not x+=y?
if we do this (good point)...
>> Seems safe to me, being restricted to string / wstring (eg, no
>> problem with basic_string specializations), I can't see how the user
>> could detect the optimization.
>
> It would be safe if you also restricted the iterator's reference type.
> I believe a user can define:
>
> std::string operator+(std::string const&,MyType){...}
> std::string operator+(std::string&&,MyType)=delete;
... then this shouldn't be an issue anymore, right?

Paolo.



More information about the Libstdc++ mailing list