Boost logo

Boost :

Subject: Re: [boost] expected<T, E...> (Was: [outcome] High level summary of review feedback accepted so far)
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2017-06-04 16:15:04


Le 04/06/2017 à 18:05, Peter Dimov via Boost a écrit :
> Vicente J. Botet Escriba wrote:
>> Le 04/06/2017 à 17:42, Peter Dimov via Boost a écrit :
>> > Vicente J. Botet Escriba wrote:
>> >> > enum unscoped_error
>> >> > {
>> >> > unscoped_other_error = 7
>> >> > };
>> >> >
>> >> > expected<double, unscoped_error> test()
>> >> > {
>> >> > return unscoped_other_error; // returns 7.0
>> >> > }
>> >
>> > ...
>> >
>> >> unexpected_type<E> is explicitly constructible from E. expected<T,
>> E> >> is implicitly constructible from unexpected_type<E>. This avoid
>> this >> kind of ambiguities.
>> >
>> > Could you please try this code with your implementation?
>>
>> It will work as yours. My concern is that this is not what we want,
>> isn't it?
>
> It's not, but what you say above - "this avoid this kind of
> ambiguities" - created the impression that you think that it isn't a
> problem.
It could be a problem for some. I'm one of the ones this is a problem.
Thanks for pointing this case.
>
> As I see it, this can be avoided by either making the constructor from
> T explicit as well, or by making the constructor from E implicit as well.
I'm all for explicit constructors, from T and from E via unexpected_type<E>.

Vicente


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