|
Boost : |
From: Itay Maman (itay_maman_at_[hidden])
Date: 2002-08-09 06:31:09
Anthony Williams wrote in a message:
>
>I've just had a thought about how to implement the strong guarantee for
variant, at the expense of larger space requirements --- have *two* copies
of >the internals, with a flag to indicate which is valid. Then, when
swapping or assigning, copy construct the value from the other variant into
the unused >space, and destruct the original and switch the flag when
everything is done.
>
>What do people think?
>
>Anthony
>
I don't think it is possible - in the general case - to create two identical
instances of a class.
Consider this class:
// Just another class
struct jac
{
jac* inst_p_;
int n_;
jac(int n = 0) : n_(n)
{
inst_p_ = this;
}
jac(const jac& other) : n_(other.n_)
inst_p_ = this;
}
jac* get() { return inst_p_; }
void set(jac* inst_p) { inst_p_ = inst_p; }
} ;
-- Itay Maman itay_maman@_yahoo_.com maman_at_il._ibm_.com This message expresses my personal opinion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk