Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-08 14:33:25


--- David Abrahams <dave_at_[hidden]> wrote:
[...]
> > typedef variant< int, my_type > v1;
> > typedef variant< my_type, int > v2;
> >
> > I think that we should just realize that
> > in the current variant, v1 and v2 have
> > a vastly different behaviour.
>
> Really? What are the differences?

my_type m;

for( i = 0; i < 10000; ++i )
   v1 = m;

for( i = 0; i < 10000; ++i )
   v2 = m;

The first loop will be executed much faster
than the second one.

--- Another example

struct my_type
{
  my_type( const m_type& l )
  {
     throw;
  }
};

v1 = 123;
v2 = 123;

v1 = m; //exception -> v1 = garbabe
v2 = m; //exception -> v2 = 123

>
> > It just goes against any conventional
> > wisdom and intuition. People, please...
> >
> > I don't think that the *weak* exception
> > safety (the way it is implement now)
>
> What is "weak" exception safety?

According to Eric,
the content *value* of a variant after an exception is not guaranteed at
all. Only the content *type* is guaranteed, and for that matter it's
only guaranteed to be one of the bounded types, not a particular one.

> IIUC the exception guarantees are the same whether or not the
> optimization takes effect.

IMHO, these "weak" guarantees worth nothing.

Eugene

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk