From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-10-10 10:05:31
Rainer Deyke wrote:
> Brock Peabody wrote:
>> (5) If variant can be singular you will need an additional case for
>> each variant and possibly turn many compile-time errors into run-time
>> This is a fact too.
> While trivially true, I doubt this is actually important in real
> code. If a variant operation that only provides the basic guarantee
> throws, the state of the variant is "valid" but undefined. This
> means that the variant contains no useful data, and the invariants of
> the piece of code which uses the variant may (temporarily) be broken.
> The only meaningful responses to the exception are therefore to
> replace the value in the variant with another (potentially resulting
> in another exception) or to destroy the variant (explicitly or
I wonder whether you can post the real code that demonstrates this. I see no
real difference between a variant of (T1, ...) and a simple T1 in this
context; if a T1 assignment that offers the basic guarantee throws, its
state is unspecified too. A variant of (T1, T2, ...), where T2 has a nothrow
assign, is better since you can force it into a valid state.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk