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

Marc Glisse marc.glisse@inria.fr
Tue Jan 11 13:18:00 GMT 2011


On Tue, 11 Jan 2011, Paolo Carlini wrote:

>> Why use x=move(x)+y and not x+=y?
> if we do this (good point)...

>> std::string operator+(std::string const&,MyType){...}
>> std::string operator+(std::string&&,MyType)=delete;
> ... then this shouldn't be an issue anymore, right?

But then the user could have defined

std::string operator+(std::string const&,MyType){...}

but not operator+=(std::string&,MyType)

If you want it to be equivalent, I don't think you can avoid making a list 
of cases known to work.

-- 
Marc Glisse



More information about the Libstdc++ mailing list