
Boost : 
Subject: Re: [boost] Interest in an 'either' library?
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 20130621 16:55:55
On Fri, Jun 21, 2013 at 12:35 PM, David Sankel <camior_at_[hidden]> wrote:
> **semantics**:
>
> template< typename left_type, typename right_type>
> struct either
> {
> // postcondition, is_left()
> either( left_type );
>
> // postcondition, is_right()
> either( right_type );
>
> bool is_left() const;
> bool is_right() const;
>
> // postcondition, is_left()
> either & operator=( left_type );
>
> // postcondition, is_right()
> either & operator=( right_type );
>
> // precondition, is_left()
> left_type left();
>
> // precondition, is_right()
> right_type right();
> private:
> };
>
> **uses**:
>
> **Use 1**: Can be used as an alternative to exceptions or the (error
> codes+set reference idiom):
>
>
There was also talk of an 'expected' class for this case (where one of the
2 choices was the, well, expected one).
I'm still hoping for that class. Although it may be syntactically the same
as 'either', I appreciate its explicit intentions.
I'm not sure if that makes 'either' less needed, and means variant +
expected ( + optional, etc) is enough.
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk