|
Boost : |
Subject: Re: [boost] Really dumb off topic question regarding variant
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-02-23 07:25:15
On 2/23/19 1:54 AM, Robert Ramey via Boost wrote:
> On 2/22/19 9:48 AM, Peter Dimov via Boost wrote:
>> I'd like to request a formal Boost review for the Variant2 library,
>> https://github.com/pdimov/variant2. Variant2 contains an
>> implementation of a
>> variant<T...> type that is an almost conforming std::variant, except it
>> doesn't require C++17 and supports C++11 and above.
>>
>> It's also never valueless and has a few other extensions.
>>
>> The same library also contains an expected<T, E...> type, which is
>> like the
>> proposed std::expected<T, E>, but supports more than one error type.
>> expected<> is not yet production-ready and has no test suite, but I will
>> finish it if the library is accepted.
>
> I see optional, expected, outcome and .. (monad?) as just special cases
> of variant. for example
>
> template<typename T>
> using optional = variant<false_type, T>;
>
> Why is it necessary to have all these types separately implemented?
> Can't there be some sort of "base" type which can be used to implement
> all these others? Wouldn't this approach make things much simpler to
> review, maintain, and use?
Interfaces and implementation of these components are very different and
optimized for their respective target use cases. They are not
specializations of the same use case, so having the same base class
(which could aid interchangeability) is not useful. The functionally
common piece of implementation is aligned_storage, and it is present as
a standalone component.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk