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 expected;
No please. Vicente