From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-08 19:58:54
--- David Abrahams <dave_at_[hidden]> wrote:
> variant<std::vector<int>, std::string> v("hello");
> v = std::vector<int>(3);
> First you destroy the contained string, then you try to construct the
> vector and it throws. The invariant says you have to contain either
> a vector or a string, but you can't get the string back; it's likely
> to throw on construction too.
> The only way to maintain the basic guarantee in this case, with this
> invariant, is to construct the vector, somewhere else, before
> destroying the string... which means on the heap or in duplicate space
> in the variant itself.
Thanks for the details. I'll sleep on it.
> That's not possible. Once option 1 (no guarantees) lets the program
> invariants break there's no way to restore them.
Did I say anything about restoring?
However I see your point.
> > I'd like to have a policy based solution.
> Sheesh. You *do*. The policy is named empty_type.
Sheesh. No, you don't. empty_type is an odd kludge...
(I don't want to repeat everything that has already
been said about it in this thread by Dave A. :)
and other people) and the memory allocations
don't have a policy.
I suggest to talk bout Eric's changes
it is in another thread.
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk