Boost logo

Boost Users :

From: Paul Grenyer (pjgrenyer_at_[hidden])
Date: 2003-07-26 18:23:09


On Sat, 2003-07-26 at 20:57, Joshua wrote:

Hi

> typedef std::vector<boost::shared_ptr<Foo> > FooVector;
>
> FooVector Foobar;
> Foo* blah = new Foo();
> boost::shared_ptr<Foo> * NewPointer = new boost::shared_ptr<Foo>(blah);
> Foobar.insert(*NewPointer); //Yes I know this looks horrible. And its probably wrong.

The above isn't quite right. You're inserting pointers to shared_ptr's.
Try this instead:

typedef std::vector<boost::shared_ptr<Foo> > FooVector;
FooVector Foobar;
Foobar.push_back( new Foo(blah) );

-- 
Regards
Paul
Paul Grenyer
Email: pjgrenyer_at_[hidden]
Web: www.paulgrenyer.co.uk
EvaneScence: http://www.evanescence.com

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