Boost logo

Boost :

From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2020-09-10 14:00:42

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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at