Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-08 15:41:09


--- David Abrahams <dave_at_[hidden]> wrote:

[...]
> > 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.
>
> Execution speed doesn't fall under what is normally termed "behavior"
> when discussing C++. As you nearly pointed out a few messages ago,
> O(N) == O(k * N).

Ok, whatever you call it "run-time behavior"?
The bottom line that the first loop is going to perform
10000 memory allocation while the second loop none
for seemingly identical variant types.

>
> > --- Another example
> >
> > struct my_type
> > {
> > my_type( const m_type& l )
> > {
> > throw;
> > }
> > };
> >
> > v1 = 123;
> > v2 = 123;
> >
> > v1 = m; //exception -> v1 = garbabe
>
> No, IIUC, v1 holds a value-initialized int in this case.

It is still different from '123', is not it?
What you point?

[...]
>
> Then you'd better trade in your std::vector<T>::insert, std::sort,
> and most of the rest of your standard library.
>
> Fortunately, you're wrong about the basic guarantee's worthlessness.

I am right. I was talking their worthlessness in regard to
variant not in general.
Even if you decide to support basic guarantees,
why do you need the heap backup and first-type based
switch?

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