Boost logo

Boost :

From: Edward Diener (eldiener_at_[hidden])
Date: 2020-09-10 17:00:53


On 9/10/2020 10:00 AM, Niall Douglas via Boost wrote:
> On 10/09/2020 14:34, Andrzej Krzemienski via Boost wrote:
>
>> 1. The usage of `nullptr` for null values. `nullptr` has been introduced to
>> mean "a pointer with null value" and is only used in the standard library
>> for smart pointers, with an ignoble exception of `std::function<>`. Using
>> it for `json::value` is not an obvious choice for me. On the other hand, we
>> do not have a universal type representing a missing value. A library could
>> provide its own `json::null`, although I am not sure if this is an ideal
>> solution either.
>
> Personally speaking, I find the use of nullptr to mean "initialise with
> null bits" fine. So, for example, you might have this:
>
> struct Foo
> {
> ...
> constexpr Foo() {} // uninitialised contents constructor
> constexpr explicit Foo(std::nullptr_t) {} // initialise contents to
> default values
> };
>
> That's the fullest extent that I would overload the use of nullptr
> however. Personally speaking, if json::value needs a null state, a
> default constructed instance seems the right approach. However if
> json::value is a variant, then monostate seems a better choice.

Did I miss something or did std::optional ( or boost::optional ) go away
as a means of saying that some value does not exist ? The nullptr is for
a null pointer. Using it otherwise seems wrong, even if the value is the
same size of a nullptr.


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