|
Boost : |
Subject: Re: [boost] Proposal: null pointer class
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-06-15 19:58:28
2009/6/15 Martin Törnwall <herede_at_[hidden]>:
>
> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk