Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext
value::value (35 of 35 overloads)

Construct from an initializer-list.

Synopsis
value(
    std::initializer_list< value_ref > init,
    storage_ptr sp = {});
Description

The contents of the initializer list are copied to the newly constructed value using the specified memory resource.

Complexity

Linear in init.size().

Exception Safety

Strong guarantee. Calls to memory_resource::allocate may throw.

Parameters

Name

Description

init

The initializer list to construct from.

sp

A pointer to the memory_resource to use. The container will acquire shared ownership of the memory resource.

Note

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


PrevUpHomeNext