Boost logo

Boost :

Subject: Re: [boost] Boost.Outcome review - First questions
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2017-05-24 16:13:10


Le 24/05/2017 à 16:52, Niall Douglas via Boost a écrit :
>>> If someone comes along with an obviously superior design to both
>>> Expected and Outcome, that would be an enormous win.
>> There's nothing much to improve upon in result/outcome as long as 4/5 of
>> the stuff is thrown out.
>>
>> template<class T> class result
>> {
>> public:
>>
>> result(); // T() or error, legitimate fork
>>
>> result( T const& );
>> result( T&& );
>>
>> result( std::error_code const& ) noexcept;
>>
>> result( result const& );
>> result( result&& );
>>
>> result( outcome const& ); //?
>> result( outcome && ); //?
>>
>> bool has_value() const noexcept;
>> bool has_error() const noexcept;
>>
>> T value() const;
>> T value() &&;
>>
>> std::error_code error() const;
>>
>> explicit operator bool() const noexcept;
>>
>> void swap( result& ) noexcept;
>> };
>>
>> That's literally it.
> You're missing a few bits of necessary stuff, like equality operators,
> initialiser list construction and so on. But essentially you've just
> specified Vicente's Expected there.
>
> If you watched my ACCU talk video, when I explain Expected I show the
> additional member functions over Optional on a second slide and it's
> only four or five additions.
>
> Peter do you think you might be happy if I extended Outcome's Expected
> implementation to instead be:
>
> template<class T, class EC = std::error_code, class E = void> class
> expected;

No please.

Vicente


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