Project: mesos
Issue MESOS-3226: Introduce an Either type.
We currently don't have an abstraction in stout to capture the notion of having a container with many types and a single value. For example, in our abstractions like Try, rather than being able to say {{Either t}} we must encode two Options ({{Option}}, {{Option}}) with the implicit invariant that exactly one will be set. This also comes in handy in many other places in the code. Note that we have the ability to (1) use C++11 unions now, as well as (2) use boost's variant directly instead of introducing Either. However, creating a named union every time this is needed is verbose, and unions require that we externally track which member is set. For variant, we already use this (e.g. json.hpp), but we can benefit from the better naming as Either. Many languages expose Either as having only two values, left and right. I'd propose making this two or more, as is the case with variant.
Story points: 5