Subject: Re: [boost] Boost.Outcome review - First questions
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-24 14:52:31
>> 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
> 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
Now expected<T, EC, E> would exactly mirror outcome/result/option,
except with no empty state and with narrow contracts on the observers.
Then it would be a perfect alternative to outcome/result/option.
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk