Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2007-05-08 10:40:34


On 5/8/07, Nat Goodspeed <ngoodspeed_at_[hidden]> wrote:
> > -----Original Message-----
> > From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> > bounces_at_[hidden]] On Behalf Of Meryl Silverburgh
> > Sent: Tuesday, May 08, 2007 9:32 AM
> > To: boost-users_at_[hidden]
> > Subject: [Boost-users] Pointer in function parameter?
> >
> > vector< boost::shared_ptr<A> > aVector;
> >
> > aFunc(aVector[0]) ; // just call a
> >
> > My question is should I change the function parameter of aFuncion from
> > this:
> >
> > void aFunc(A* aPtr) {
> > // access aPtr
> > }
> >
> > to this:
> >
> > void aFunc(shared_ptr<A> aPtr) {
> > // access aPtr
> > }
>
> [Nat] Looks reasonable to me... I believe the docs say that it's
> conventional to pass shared_ptr by value rather than (e.g.) const
> reference so that the ref count will be adjusted properly.

Thanks. But what if I have

void aFunc(const A* aPtr) {
 // access aPtr
 }

should I change it to

void aFunc(const shared_ptr<A> aPtr) {
 // access aPtr
 }

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net