![]() |
Convert an object of type T
to value
.
Defined in header <boost/json/value_from.hpp>
template< class T> value value_from( T&& t, storage_ptr sp = {});
This function attempts to convert an object of type T
to value
using
value
's
constructors,
tag_invoke
.
In all cases, the conversion is done by calling an overload of tag_invoke
, passing an lvalue jv
of type value
as an argument to ensure that
the result of the conversion uses the correct storage_ptr
.
The function used to convert an expression e
of type T
is determined as
follows. Let S be the set of all declarations found
by argument-dependent lookup for the function call
tag_invoke( value_from_tag(), jv, e )
Then, an attempt to find an applicable library-provided conversion (if any) is made. Add to S
std::is_assignable<value&,
T&&>value
, otherwise,
T
satisfies TupleLike,
otherwise,
T
satisfies FromMapLike,
otherwise,
T
satisfies FromContainerLike, otherwise,
If a library-provided conversion is added to S, it has the form
template<typename U> void tag_invoke( value_from_tag, value&, U&& );
Using S, overload resolution is performed to find the
single best candidate to convert e
to value
.
If more than one function is found or if no viable function is found, the
conversion fails. Otherwise, the selected function F
is called with F(
value_from_tag(),
jv, std::forward< T >( from ) )
and the
value of jv
after modification
by F
is returned as the result
of the conversion.
Strong guarantee.
Type |
Description |
---|---|
|
The type of the object to convert. |
t
converted to value
.
Name |
Description |
---|---|
|
The object to convert. |
|
A storage pointer referring to the memory resource to use for the
returned |
value_to
,
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf
Convenience header <boost/json.hpp>