Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-08 17:14:56


"E. Gladyshev" <egladysh_at_[hidden]> writes:

> --- David Abrahams <dave_at_[hidden]> wrote:
> [...]
>
>> Sorry to be so blunt, but that's just crazy. Without the basic
>> guarantee, any program invariant is allowed to be disrupted by an
>> exception, and recovery is impossible.
>
> I don't get what you mean. I can always handle exceptions
> on my own just like in case of typical class or C style union
> types. What is so special about variant?

Nothing at all. The basic guarantee is just about the minimum
required for exception recovery with *any* component.

> What is program invariant?

http://tinyurl.com/q8kt

>> > Even if you decide to support basic guarantees, why do you need the
>> > heap backup and first-type based switch?
>>
>> Because of variant's invariant: "thou shalt always contain a value of
>> one of your types".
>
> Who said that?

It's part of variant's spec.

http://www.cs.rpi.edu/~gregod/boost/doc/html/variant.misc.html

  "Boost.Variant guarantees the type of its content is one of a
   finite, user-specified set of types"

It would be nice if this invariant were made more explicit in the
documentation.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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