Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr question
From: Michael Jackson (mike.jackson_at_[hidden])
Date: 2010-05-18 10:38:34


On 5/18/10 12:00 AM, in article 37128.3139721074$1274188512_at_[hidden],
"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

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