Boost logo

Boost :

Subject: Re: [boost] [config] Macro for null pointer
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-12-07 01:03:45


On Wed, Dec 5, 2012 at 10:10 PM, Andrey Semashev
<andrey.semashev_at_[hidden]>wrote:

> 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.
>

Well, I think some individuals here (I'd put myself in that camp) are
opposed to injecting anything into the global namespace if it can be
helped, and here it certainly can be helped. So if we add a nullptr
emulation in Boost, it's going to have to be paired with a using macro, a
different name (i.e., boost::nullptr_), or both. If no one will use this
utility given the latter imperfections, I'm fine with just dropping the
proposal altogether and everyone can go back to using NULL or C++11.

- Jeff


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