...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The type used in initializer lists.
Defined in header <boost/json/value_ref.hpp>
class value_ref;
Name |
Description |
---|---|
value_ref [constructor] |
Constructor. |
This type is used in initializer lists for lazy construction of and assignment
to the container types value
, array
, and object
. The two types of initializer
lists used are:
A value_ref
uses reference
semantics. Creation of the actual container from the initializer list is
lazily deferred until the list is used. This means that the boost::container::pmr::memory_resource
used to construct a container can be specified after the point where the
initializer list is specified.
This example demonstrates how a user-defined type containing a JSON value can be constructed from an initializer list:
class my_type { value jv_; public: my_type( std::initializer_list< value_ref > init ) : jv_(init) { } };
Never declare a variable of type std::initializer_list
except in function parameter lists, otherwise the behavior may be undefined.
Convenience header <boost/json.hpp>