Boost logo

Boost :

Subject: Re: [boost] [hana]Either generalization & missing variant
From: Larry Evans (cppljevans_at_[hidden])
Date: 2015-06-08 12:53:17


On 06/08/2015 10:12 AM, Larry Evans wrote:
[snip]

> wrappers. Why not provide wrapper's tagged by some
> enumerable? For example, something like this:
>
> template
> < typename X
> , typename Enumerable=unsigned
> , Enumerable tag=Tag()
> >
> struct _tagged //instead of _left and _right
> : operators::adl
> {
> X value;
> .
> .
> .
> template <typename... F>
> constexpr decltype(auto) go(F...&& f) const&
> { return (hana::arg<unsigned(tag)>(f...))(value);
> }
> .
> .
> .
> };
>
> This would be more general than the binary Either. In
> addition, _tagged could be used elsewhere. For example, it
> could be used in a multiple inheritance implementation of
> tuple.

Which I see hana actually does here:

https://github.com/ldionne/hana/blob/master/include/boost/hana/detail/closure.hpp#L26

but instead of _tagged<X,n>, element<n,X> is used where element is at:

https://github.com/ldionne/hana/blob/master/include/boost/hana/detail/closure.hpp#L20

[snip]


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