Boost logo

Boost :

Subject: Re: [boost] [operators] What is the correct overload set for a binary operator?
From: Andrew Ho (helloworld922_at_[hidden])
Date: 2013-04-28 17:13:48


> Which set is "Mark's set"? The last one I posted ~100 minutes ago using
the signatures mentioned by Mark and
> including an implementation?
>

Yeah, when I did the tests your post wasn't up yet, but we have essentially
the exact same implementation of Mark's idea.

> It's still slower depending on the cost of the move, only for some classes
the compiler can optimize that
> cost away.

I take it you're comparing the return rvalue vs. return rvalue ref? If so,
quite possibly yes. I'll see if I can't identify under what practical
situations this solution performs worse compared to returning r-value refs.

> Anyways, let's explore the best "return rvalues" version. I think the last
version I posted
> should be really close, except if someone can come up with a pass-by-value
version and expressions where
> it works better in practice.
>
> I think that for now we might start with the code I posted and if future
compilers are able to support and
> optimize pass-by-value to allow even better code, we might detect these
compilers and use a different implementation.
>

Sounds good to me.

FWIW, I extended this solution to the other cases. All other cases have 4
overloads except for commutative T + U which has 8. It should be a
copy/paste replacement that should work with the operators2.hpp test-bed.
Link: http://codepad.org/HdII3G0b


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk