Boost logo

Boost Users :

From: Jens Seidel (jensseidel_at_[hidden])
Date: 2008-06-16 09:38:51


On Mon, Jun 16, 2008 at 01:01:58PM +0200, Ovanes Markarian wrote:
> On Mon, Jun 16, 2008 at 10:45 AM, Marc Horowitz <marc_at_[hidden]> wrote:
> > "Ovanes Markarian" <om_boost_at_[hidden]> writes:
> >
> > >> in this case template deduction does not work (or works a bit
> > >> different as assumed).
> > >>
> > >> This one should work:
> > >> (std::tr1::bind(f, _1))(static_cast<const char*>(NULL));
> >
> This is static type safety of C++. The next standard will introduce
> null_ptr. If used as you suggested, then nothing prevents this BAD code to

Right, null_ptr will be part of C++. Nevertheless NULL was never part of
C++! g++ defines it for convenience, the Intel compiler does not.

It is often defined by 3rd libraries. glib uses:
#ifndef NULL
# ifdef __cplusplus
# define NULL (0L)
# else /* !__cplusplus */
# define NULL ((void*) 0)
# endif /* !__cplusplus */
#endif

/usr/include/linux/stddef.h is similar but uses 0 instead of 0L in C++
mode.

Nevertheless even with nullptr as defined as in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1601.pdf
I wasn't able to let the Intel compiler warning
warning #1881: argument must be a constant null pointer value
vanish. The code I used is:
XtVaCreateManagedWidget("widget_name", xmFrameWidgetClass, form, NULL);
(where I replaced NULL by nullptr, ...)

So don't rely on NULL. It's evil ...
null_ptr doesn't help in all cases as well :-)

Jens


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