Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-08 20:47:06

--- 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.

Could it be done on the stack and not on heap or duplicate space?
I think that I can outline a solution about how to do it
w/o heap or duplicate space.


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

Boost list run by bdawes at, gregod at, cpdaniel at, john at