Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-10-28 01:45:14


E. Gladyshev wrote:
> Also, I mentioned it to Eric that the current
> implementation doesn't actually provide basic guarantees.
> He was going to look into that.

Are you referring to the following problem?

   T f();

   class my_type
     T t_;
     my_type() { }
     my_type(const my_type& other)
       : t_( f() )

   variant< int, my_type > v;

   int main()
     my_type m1;

     my_type m2 = m1; // ok
     v = m1; // potentially undefined: does f visit v?

If so, then yes, I've devised a solution for that problem, but it incurs
quite a costly run-time overhead (i.e., a backup copy of lhs content
required even when heap backup of lhs content is not).

A better solution, I believe, is simply to document that accessing a
variant *during* assignment will result in undefined behavior. That way,
unless the user really needs to do something like the above, such (IMHO,
excessive) overhead will be avoided.

If you're *not* referring the above problem, then I'd like to know when
else variant does not provide the basic guarantee.


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