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

This is the documentation for a snapshot of the develop branch, built from commit 09e5370574.
PrevUpHomeNext
value_from (1 of 4 overloads)

Convert an object of type T to value.

Synopsis

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

template<
    class T,
    class Context>
void
value_from(
    T&& t,
    Context const& ctx,
    value& jv);
Description

This function attempts to convert an object of type T to value using

Out of the box the function supports types satisfying SequenceContainer, arrays, arithmetic types, bool, std::tuple, std::pair, std::variant, std::optional, std::monostate, and std::nullopt_t.

Conversion of other types is done by calling an overload of tag_invoke found by argument-dependent lookup. Its signature should be similar to:

template< class FullContext >
void tag_invoke( value_from_tag, value&, T,  const Context& , const FullContext& );

or

void tag_invoke( value_from_tag, value&, T,  const Context& );

or

void tag_invoke( value_from_tag, value&, T );

The overloads are checked for existence in that order and the first that matches will be selected.

The ctx argument can be used either as a tag type to provide conversions for third-party types, or to pass extra data to the conversion function.

Exception Safety

Strong guarantee.

Template Parameters

Type

Description

T

The type of the object to convert.

Context

The type of context passed to the conversion function.

Parameters

Name

Description

t

The object to convert.

ctx

Context passed to the conversion function.

jv

value out parameter.

See Also

value_from_tag, value_to, tag_invoke: A general pattern for supporting customisable functions

Convenience header <boost/json.hpp>


PrevUpHomeNext