Boost logo

Boost :

Subject: Re: [boost] [multiprecision] Some rvalue reference experiments (performance inhancements #1)
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2012-06-30 15:56:19

On Sat, 30 Jun 2012, Steven Watanabe wrote:

> On 06/30/2012 11:08 AM, John Maddock wrote:
>>> The safe solution is returning Number, not Number&&. If Dave reads
>>> this message, he can probably point us to previous discussions about
>>> this. Being able to return Number&& would be great...
>> Can you explain why it's unsafe given that we know that the value
>> returned is an rvalue ref already?
> I'm guessing that it has something to do with temporary lifetimes?

I think so. Trying to find back how some people managed to convince me it
was unsafe, all I managed to find right now is a statement by Dave that
Howard generally advised against function returning rvalue references...

One easy issue I can see (in code right in front of me) is:

const NT& result=a*d-b*c;

Using const references instead of plain variables is something that quite
a number of people do, and which (I think) would fail if operator-
returned a reference.

Note that it also means that the unary operator+ (which I hope noone ever
uses) is "unsafe" in a number of libraries.

Marc Glisse

Boost list run by bdawes at, gregod at, cpdaniel at, john at