Boost logo

Boost :

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


"Darren Cook" <darren_at_[hidden]> wrote in message
news:3FE77A19.7050409_at_dcook.org...
> > 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:
> >
> >
http://62.79.25.205/nesotto/boost-sandbox/libs/ptr_container/doc/ptr_container.html
>
> 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.

>or
> 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.

br

Thorsten


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