Boost logo

Boost Users :

Subject: [Boost-users] passing a shared pointer
From: Lloyd (lloyd_at_[hidden])
Date: 2010-06-09 09:20:33


Hi,

I have a shared pointer like this

class a
{
};

boost::shared_ptr<a> Ptr(new a());

I need to pass this pointer as an argument to function (MyFunc) which access this as a reference

void MyFunc(a& ref)
{
}

Now I am calling the function like this

MyFunc(*Ptr);

But this causes the "Ptr" to destroy early (I am using this for an asynchronous-ASIO- operation)

How can I do this right?

Thanks a lot,
  Lloyd

______________________________________
Scanned and protected by Email scanner



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