Boost logo

Boost :

Subject: Re: [boost] Outcome v2 is feature complete
From: Peter Dimov (lists_at_[hidden])
Date: 2017-07-11 11:21:08


Niall Douglas wrote:

> Github: https://github.com/ned14/outcome
>
> Docs (highly incomplete): https://ned14.github.io/outcome/

This is a welcome development, if still a bit too-policy-heavy for my taste.

Regarding construction, I have the following suggestion.

Instead of reusing in_place_type, use the following tag types:

struct in_place_value_t
{
    constexpr in_place_value_t() noexcept {}
};

constexpr in_place_value_t in_place_value;

struct in_place_error_t
{
    constexpr in_place_error_t() noexcept {}
};

constexpr in_place_error_t in_place_error;

This is isomorphic but superior to using in_place_index<0> and
in_place_index<1>, which were my initial choice. Now the ambiguity when T ==
EC is resolved and

template<class... A> result( in_place_value_t, A&&... a );

always initializes the value and does not need to be disabled when T == EC.

In addition, I would add

template<class... A> result( A&&... a );

which initializes the value when it's constructible from a..., the error
when that's constructible from a..., and is disabled when neither or both
are constructible. (The implicit/explicit duality when sizeof...(A) == 1
complicates the actual implementation of the above but conceptually it still
works as explained. Also, the sizeof...(A) == 0 case needs to be disabled.)


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