Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-12-22 20:31:50

"Darren Cook" <darren_at_[hidden]> wrote in message
> > I've just uploaded the first version of a library that provides
> > standard-like
> > containers specialized for pointers.
> >...
> > The docs can be browsed online here:
> >
> >
> I think the example needs to be more motivating :-).

well, it's hard to put all the benefits into one small introducing example,
but it could be beter than that.

> Using normal vector:
> for_each( svec.begin(), svec.end(), PolyPtrOps() );
> Using your class:
> for_each( pvec.begin(), pvec.end(), mem_fun_ref( &Poly::foo ) );
> If saving writing a functor is all then we might as well use boost lambda

not if we need to reuse the functor; you can't store a lambda expression and
use it later.
PolyPtrOps() could be more complicated that shown.

> bind:
> for_each( svec.begin(), svec.end(), bind(&Poly::foo,_1) );

does bind really works with smart pointers?

> Yes, I read the advantages and they sound good; I just think you need an
> example to show them off

I'll think about adding them.

>(and perhaps some benchmarks as you say it should
> be quicker and use less memory than smart pointers).

It depends of your code and what semantics you want, but usually when having
a big bunch of polymophic objects,
it is a simple fact. You can also check NTL's benchmarks or look at the
smart pointer timings/memory usage compared to
naked pointers. Regarding memory,
if you objects are big, then the memory overhead will of course be small,
but if your objects are small it will be very big.



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