
4 Oct
2011
4 Oct
'11
10:24 p.m.
on Tue Oct 04 2011, Nevin Liber <nevin-AT-eviloverlord.com> wrote:
On 4 October 2011 16:05, Matt Calabrese <rivorus@gmail.com> wrote:
Type&& operator +( Type&& left, Type const& right ) { left += right; return std::move( left ); }
Anyway, as was pointed out, this is probably not a good idea for other reasons, such as people expecting to be able to bind the result to a reference and have its life extended (though I suppose you could just rule-out such uses as valid when the base is used).
What happens with:
Type t = TypeFactory(); auto sum = TypeFactory() + t;
That one's fine; sum is deduced to have a non-reference type. -- Dave Abrahams BoostPro Computing http://www.boostpro.com