value_ref
The type used in initializer lists.
Synopsis
Defined in header <boost/json/value_ref.hpp>.
class value_ref;
Member Functions
Name | Description |
---|---|
|
Constructor. |
Description
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.
Example
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 |
See Also
Convenience header <boost/json.hpp>.