Boost logo

Boost :

Subject: Re: [boost] [operators] What is the correct overload set for a binary operator?
From: Daniel Frey (d.frey_at_[hidden])
Date: 2013-04-28 16:47:27


On 28.04.2013, at 21:47, Andrew Ho <helloworld922_at_[hidden]> wrote:

> Yeah, I did some testing with VS2012 (/O2 optimizations) using your original
> set and with Marc's set. Both work, but Marc's set does result in fewer

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

> temporaries all-together. To be specific, all internal moves seem to be
> optimized away, only move required is moving into the result variable. I
> think this provides all of the benefits of your previous rvalue-ref code
> without the unsafe behavior.

It's still slower depending on the cost of the move, only for some classes the compiler can optimize that cost away. 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.


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