Re: [Boost-users] shared_ptr question

On 5/18/10 12:00 AM, in article 37128.3139721074$1274188512@news.gmane.org, "David Michael Bond" wrote:
rx = processing_queue.back( ) ; if( rx ) {
I think your problem is the misunderstanding of the shared_ptr. The shared_ptr is a class that _wraps_ another pointer (whether valid or not) and keeps a reference count to how many other variables are using the pointer. The following line: if (rx) is only testing if the wrapper is valid, NOT the actual pointer itself that is being wrapped. What you really want is: If (rx.get() != NULL) -- Mike Jackson

On 5/18/2010 9:38 AM, Michael Jackson wrote:
if (rx)
is only testing if the wrapper is valid, NOT the actual pointer itself that is being wrapped. What you really want is:
If (rx.get() != NULL)
No, you don't need that. http://www.boost.org/doc/libs/1_43_0/libs/smart_ptr/shared_ptr.htm#conversio...

On 5/18/10 10:52 AM, in article 4BF2A9C4.7060601@holtmans.com, "Eric J. Holtman" wrote:
On 5/18/2010 9:38 AM, Michael Jackson wrote:
if (rx)
is only testing if the wrapper is valid, NOT the actual pointer itself that is being wrapped. What you really want is:
If (rx.get() != NULL)
No, you don't need that.
http://www.boost.org/doc/libs/1_43_0/libs/smart_ptr/shared_ptr.htm#conversio... Cool, I guess we learn something new everyday.
Thanks -- Mike Jackson
participants (2)
-
Eric J. Holtman
-
Michael Jackson