Boost logo

Boost :

Subject: Re: [boost] [err] RFC
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-11-19 17:06:54


On 20/11/2015 04:58, Domagoj Šarić wrote:

>> The more problematic case is if the combiner was not expecting
>> failure, and so someone used the same expression with a combiner that
>> accepted T. So the compiler calls all three calc methods
>> (constructing fallible_result<T>s along the way), then gets around to
>> converting the first one back to T, which throws. This is ok, but
>> then the other two are destroyed; and if at least one of these throws
>> too, then you're dead.
>
> As explained before this cannot happen as even the implicit conversion
> operators work only on rvalues...

The result of a function call that returns either a bare T or a T&& is
an rvalue.

Your asserts will prevent this particular usage, but that's the only
thing that does. And asserts don't fire until runtime, so if it's an
infrequently exercised path (without a unit test) this may go unnoticed
for quite a while. Especially if people are in the habit of testing
release builds (which is not that uncommon).


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