On Sun, Jun 23, 2013 at 5:07 AM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
On 22/06/13 15:11, David Sankel wrote:
Good question. I think the tradeoffs that were made with Boost.Variant in
that case would work just as well here.
Don't you already have an implementation? What does it do?
I do, now that you ask, at https://github.com/camio/Boost.Either. This reference implementation uses Boost.Variant as a back-end and thus inherits a lot of its behavior. Let me try to summarize what precisely happens in the case you were originally inquiring upon (what happens with exceptions in assignments): 1. For types where this can happen, the resulting state will still have all the invariants of the either type met. That is, it will always refer to either a 'left' or a 'right' value. 2. Because of point one, the use of internal types that have throwing assignments may incur an allocation during these operations in order to ensure #1 is met. 3. Ways will be provided to workaround the overhead in #2 for capable types. More details here: http://www.boost.org/doc/libs/1_49_0/doc/html/variant/design.html#variant.de... -- David Sankel