Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

value_ref

The type used in initializer lists.

Synopsis

Defined in header <boost/json/value_ref.hpp>

class value_ref
Member Functions

Name

Description

value_ref

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 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)
    {
    }
};
Remarks

Never declare a variable of type std::initializer_list except in function parameter lists, otherwise the behavior may be undefined.

See Also

value, array, object

Convenience header <boost/json.hpp>


PrevUpHomeNext