
On 12/07/2017 02:18, Niall Douglas wrote:
On 11/07/2017 12:53, Peter Dimov wrote:
I would make outcome<> reuse 100% of result<>'s implementation, by stealing another page from your playbook:
class extended_error_code { std::error_code e_; std::exception_ptr x_; };
template<class T> using outcome = result
; That may well happen yet. What held me back was that the universality of EC = error_code is very important in order to use TRY effectively. That's what led to the split design you see today, so you're basically exchanging some purity in the design for ease of programming. TRY is such a boon for not typing boilerplate.
Perhaps:
struct extended_error_code : public std::error_code
{
std::exception_ptr ex;
};
template<class T> using outcome = result
A majority of peer review feedback didn't see the need for variant storage. Eliminating it very significantly reduces the complexity of the implementation, it's a big gain. I was able to SFINAE all the constructors because of the compile time budget released by eliminating the variant storage.
If you're going to maintain strict no-value-plus-error semantics then union/variant storage makes sense, as otherwise you're wasting memory. I'm not sure why this would increase complexity.