I can't really agree or disagree, as my information comes from an article I read a long time ago. It stated that the portable way to assign NULL to a pointer is to first cast it to the type of the lvalue. At the very least I would expect (out of pessimism) SOME compiler in the world today to throw a warning when it sees this:

class foo {};
foo* myfoo = 0;

However, I haven't personally tried this. In all honesty I don't see any reason why the compiler would ever need to complain about this since I don't foresee any problems with assigning an integral constant of 0 to pointer types, or even using them during comparisons. However I guess if you guys say that it is portable, I suppose I should just save myself some executable size and avoid the use of nullptr. At this point the only real use I see in a nullptr class/struct is for readability.

Where in the standard does it state that assigning an integral constant to a pointer type is legal? Perhaps there is some more generic rule in the standard to which this concept applies.

On Jan 2, 2008 4:17 PM, Scott McMurray <me22.ca+boost@gmail.com> wrote:
On 02/01/2008, Robert Dailey <rcdailey@gmail.com> wrote:
> They are unrelated types.
>

But 0 is a compile-time integral constant with value 0, and is
therefore implicitly convertible to any null pointer.  Why do you
think the comparison is any less portable than the initialization?

And the reinterpret_cast is actually less portable, since it assumes
that the null pointer is represented by a null bit sequence.  The
correct way to cast 0 to a null pointer is through static_cast (or
boost::implicit_cast).
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users