Boost logo

Boost :

From: Michael Marcin (mike_at_[hidden])
Date: 2007-07-31 15:53:17


Chris Fairles wrote:
> This was a proposed library implementation of nullptr for c++0x from
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1601.pdf
>
> const // this is a const object...
> class {
> public:
> template<class T> // convertible to any type
> operator T*() const // of null non-member
> { return 0; } // pointer...
> template<class C, class T> // or any type of null
> operator T C::*() const // member pointer...
> { return 0; }
> private:
> void operator&() const; // whose address can't be taken
> } nullptr = {}; // and whose name is nullptr
>
> Very similar to your impl although I think the static_cast in yours is
> redundant. The standard says, 0, being an integral constant expression
> that evaluates to zero, is a null pointer constant which is implicitly
> convertible to a pointer type (4.10)
>

Cute. It might be nice to have this as a Boost utility library.

Thanks for the link,

Michael Marcin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk