Boost logo

Boost Users :

From: Victor A. Wagner Jr. (vawjr_at_[hidden])
Date: 2008-01-02 19:40:56


Robert Dailey wrote:
> Hi,
>
> Does boost have some sort of null_ptr class that allows you to do
> portable NULL comparisons? For example, the following isn't portable:
>
> char* foo = 0;
> if( foo != 0 )
> {
> }
 if (foo)
 {
 }
should be portable also
>
> But this is portable:
>
> char* foo = reinterpret_cast<char*>( 0 );
> if( foo != reinterpret_cast<char*>( 0 ) )
> {
> }
>
> You could easily create a null_ptr class with a few global template
> operators to make this easy, so you could do this:
I understand there are enough people who dislike if (foo) and
if(!foo) that adding a "null" is going into c+0x
I personally like the (foo) and (!foo) notation and think "needing" a
"NULL" is pointless given the other holes in the language

>
> char* foo = boost::null_ptr;
> if( foo != boost::null_ptr )
> {
> }
>
> Is there such a thing? Thanks.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



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