Boost logo

Boost :

Subject: Re: [boost] [config] Macro for null pointer
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-12-06 01:10:19


On Thu, Dec 6, 2012 at 7:42 AM, Jeffrey Lee Hellrung, Jr.
<jeffrey.hellrung_at_[hidden]> wrote:
>
> Or, as Nathan suggested, drop trying to emulate the literal nullptr keyword
> and just define and use boost::nullptr_. That's probably the best option.
> Slightly uglier, but no macros and no name collisions.

Nathan's code sample has an error, it always uses
boost::detail::nullptr_t to define nullptr_. After correcting this I'm
not sure that the following:

namespace boost {

typedef std::nullptr_t nullptr_t;
const nullptr_t nullptr_ = {};

}

is valid and supposed to work. If I'm not mistaken, we know almost
nothing about std::nullptr_t. In particular, we don't know if it's
default constructible and if it is, will it be equivalent to nullptr.

Also, boost::nullptr is supposed to help writing C++11-style code even
for C++03 compilers. With a different keyword that doesn't hold
anymore, a migration path is needed. I'm not sure it's worth the
effort in this case.


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