Boost logo

Boost :

Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-30 21:01:05


Andrzej Krzemienski wrote:
> ```
> expected<vector<T>> mahe_vec()
> {
> expected<vector<T>> ans {value}; // creates an empty vector in-place
> vector<T> & vec = ans.value();
> // ...
> }
> ```
> Niall has indicated a number of times that the second defensive if is
> removed in context like the following:
>
> ```
> if (ans.has_value())
> ans.value(); // second check elided
> ```
>
> But in my case with `vector` there is no first check, but I am still sure
> the value is there because I can trace the entire (quite triviall)
> life-time of the object.

It's still elided, because the compiler can see that you're doing the
equivalent of storing `true` into `has_value_`.


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