
On Tue, Oct 4, 2011 at 6:01 PM, GMan <gmannickg@gmail.com> wrote:
If we're going for C++11, I think the correct way to do this is with a single function:
type operator+(type lhs, const type& rhs) { lhs += rhs; return lhs; }
That should, given that the class implements move-semantics, be sufficient.
If you do that then what does the version look like if the right hand operand is the moved-from operand? If you do: type operator+( const type& lhs, type rhs ) { /*...*/ } Then neither one of the two overloads is a better match over the other, regardless of which and how many operands are r-values as opposed to l-values. Being explicit with r-value references and l-value references disambiguates so that there is no problem. It is interesting to note that IIRC Boost.Operators already does do the value-type for operand form, at least on certain compilers, meaning that current Boost.Operators is already partially move-aware to some extent. -- -Matt Calabrese