...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Construct from an initializer-list.
value( std::initializer_list< value_ref > init, storage_ptr sp = {});
The contents of the initializer list are copied to the newly constructed value using the specified memory resource.
Linear in init.size()
.
Strong guarantee. Calls to memory_resource::allocate
may throw.
Name |
Description |
---|---|
|
The initializer list to construct from. |
|
A pointer to the |
The previous behavior of this constructor was to always construct either
an object
or an array
.
In practice though, several C++ implementations did not treat value{x}
as a constructor from initializer list. This effectively resulted in
different behavior on different implementations.
If you need the legacy behavior define macro BOOST_JSON_LEGACY_INIT_LIST_BEHAVIOR
when you are building the library. The macro and the functionality will
be deprecated in the future and then removed, so we urge you to change
your code for the new behavior as soon as possible. The simplest way
to create an array
with 1 element using an
initializer list is via array{x}
.