|
Boost : |
Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2017-05-30 14:01:49
On Tue, May 30, 2017 at 3:51 PM, Niall Douglas via Boost <
boost_at_[hidden]> wrote:
> On 30/05/2017 13:25, Peter Dimov via Boost wrote:
> > Niall Douglas wrote:
> > There is a middle ground here, which I was pondering for a while, make
> > has_value return T* instead of bool.
>
> It's a clever idea, but it reminds me too much of C++ 98 days of
> returning void * and such to implement boolean testing. We all got badly
> bitten with those tricks
But that was mostly from implicit conversions though, while here it's an
explicit method call.
My concern is more that I expect a has_value() method to return a boolean,
not a pointer.
value_if() OTOH is elegant, almost self-explanatory, and the if(auto* p =
o.value_if()) idiom
is quite readable, despite the two ifs. FWIW. --DD
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk