
15 Jun
2009
15 Jun
'09
11:58 p.m.
2009/6/15 Martin Törnwall <herede@tngemu.com>:
int main() { func(NULL); func(null_ptr<char>()); }
When passing NULL, f(int) will be called -- probably not what the programmer intended. The second call utilizes null_ptr<char> to guarantee that the overload of f() taking char* will be called instead of the one taking int. As noted above, my null_ptr class also handles multiple overloads taking pointer types gracefully. Please let me know what you think!
I think that the advantage of nullptr is not needing to specify the class -- I'm not convinced that I'd actually bother #including something so I can type the longer null_ptr<T>() instead of (T*)0.