Boost logo

Boost :

Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-05-30 19:27:15


2017-05-30 1:41 GMT+02:00 Gavin Lambert via Boost <boost_at_[hidden]>:

> On 30/05/2017 11:25, Vicente J. Botet Escriba wrote:
>
>> Le 29/05/2017 à 17:05, Niall Douglas a écrit :
>>
>>> - error_type& .error_raw() - reinterpret_cast<error_type&>
>>>>>
>>>> evidently we don't like the _raw suffix.
>>>>
>>> .error_unsafe(), .unsafe_error(), .unchecked_error() all work for me too.
>>>
>> How likes any of those?
>> Who prefers error() to throw if there is a value? or return by value and
>> return E{} when there is a value and I don't know hat when there is an
>> exception_ptr?
>>
>
> FWIW, my preferred options would be (which I think were the originals):
>
> - value() throws if holding error or exception (or empty)
>
> - error() returns E{} if holding value or E{errc::has_exception} if
> holding exception, or E{errc::no_value} if empty (names made up on the
> spot, doesn't matter)
>
> - exception() returns nullptr if holding value or error or empty
>
> These seem like safe and reasonable defaults and permits code to always
> extract an error_code or exception_ptr even on success, which can aid
> certain interop scenarios with older APIs and otherwise simplify caller
> logic.
>

I more-less agree with this position. I just with you didn't use word
"safe". It carries emotional rather than technical value.

>
> I would prefer that unchecked_* (or whatever) versions did not exist as
> then nobody would accidentally call them and perhaps introduce UB. But I'm
> not strongly opposed to them.

If you have somebdy who *accidentally* calls member functions in the
program, using "checked" versions is not going to help much.

Regards,
&rzej;


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