|
Boost Users : |
From: dick.bridges_at_[hidden]
Date: 2002-12-12 12:19:27
I should point out that I went 'back' to get() because I got tired of
explaining the 'correct' way [ie, if( b ) ] Darin Adler provided in his
answer.
|---------+---------------------------------------------------->
| | Dick |
| | Bridges/CSE/IRV/CONTRACTOR/TOSHIBA-TAIS_at_T|
| | OSHIBA-TAIS |
| | |
| | 12/12/2002 08:07 AM |
| | Please respond to Boost-Users |
| | |
|---------+---------------------------------------------------->
>----------------------------------------------------------------------------------------------|
| |
| To: Boost-Users_at_[hidden] |
| cc: |
| Subject: Re: [Boost-Users] testing if shared_ptr has been assigned |
>----------------------------------------------------------------------------------------------|
>From the docs:
<snippet>
get
T * get() const; // never throws
Returns: the stored pointer.
Throws: nothing.
</snippet>
Therefore you can use
if( b.get() )
or
if( b.get() == NULL )
"TEA Hartmann,
Steven" To:
boost-users_at_[hidden]
<SHartmann_at_aus.t cc:
elusa.com> Subject: [Boost-Users]
testing if shared_ptr has been assigned
12/11/2002 11:01
AM
Please respond
to Boost-Users
I need some help in testing for the condition of whether a shared_ptr has
been assigned. In the following example, the "if( b != NULL ) does not
work. How would I do this test?
typedef boost::shared_ptr<int> IPtr;
int i( 0 );
IPtr a( i );
IPtr b;
if( some condition )
b = a;
if( b != NULL ) { // How should this really be coded?
}
Best Regards,
Steve
[Non-text portions of this message have been removed]
Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
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