Boost logo

Boost Users :

Subject: [Boost-users] shared_ptr usage
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-05-06 16:32:46


Hello,

 

I have a class that stores a private member a shared_ptr<T> that points to a
dynamically allocated instance of T.

A getter member function returns T&.

 

I now realise that in a snippet, I would like to store a new shared_ptr<T>
to that returned object.

     T& t = myinstance.getT();

I would like to store t in a shared_ptr, ie increment the count of shared
pointers

Do I do:

    shared_ptr<T> desiredPointer( &t );

 

will this increment the count of shared pointers to t?

 

Regards,



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