News for hackers. Stuff that matters.
Re:C++ 11 Approved by vog on Saturday August 13, 2011 @05:45AM (#2880684)
> explicit strong nullptr constant; no more NULL macro nonsense

What is the point of this? C++ defines the null pointer to be always 0. So I never needed the NULL macro in C++ anyway, as I'm allowed to simply type 0 instead.

In how far is that new nullptr constant preferable to writing simply 0?

Re:C++ 11 Approved by Someone on Saturday August 13, 2011 @09:23AM (#2880920)
The standard example is:

    void f(int x);
    void f(char *x);
    ...
    f(0);  // calls void f(int)
That may seem contrived, but you may not know of the f(int) overload, especially in combination with templates.

NULL, if #define'd as (void *)0, prevents that error.

Re:C++ 11 Approved by pmjordan on Saturday August 13, 2011 @06:03PM (#2882117)
NULL is actually #defined to 0 in C++ as void* is not implicitly convertible to any pointer type as it is in C. So unlike in C there has been no safety in using NULL. Until now.
Re:C++ 11 Approved by FrankBooth on Saturday August 13, 2011 @08:47AM (#2880859)
Consider:

  int execl(const char *path, const char *arg, ...);
called like so:

  execl("foo", "bar", 0);
Particularly when sizeof(int) != sizeof(void *).
Re:C++ 11 Approved by biot on Saturday August 13, 2011 @06:13AM (#2880711)
You may know that a null pointer is always 0, but you don't know that 0 is always a null pointer -- it may be the result of subtracting an integer from itself. That's the difference.
Re:C++ 11 Approved by doug363 on Saturday August 13, 2011 @09:00AM (#2880878)
In overloaded or argument-deduced contexts, then "0" is preferentially an int, but nullptr is never an int.
Re:C++ 11 Approved by exDM69 on Saturday August 13, 2011 @05:56AM (#2880693)
It's all about compile time warnings and static type information. The resulting code should be the same whether you're using 0, NULL or nullptr.
Re:C++ 11 Approved by xilun0 on Sunday August 14, 2011 @01:08AM (#2882848)
not e.g. with 64-bits, va args and literal 0 (cf FrankBooth example)