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 an older version of Boost and was released in 2022. The current version is 1.90.0.
Convert a value
to a result
of T.
Defined in header <boost/json/value_to.hpp>
template< class T> result_for< T, value >::type try_value_to( const value& jv);
This function attempts to convert a value to result<T>
using
value's
accessors, or
tag_invoke.
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:
result<T> tag_invoke( try_value_to_tag<T>, value const& );
If an error occurs during conversion, the result will store the error code
associated with the error. If an exception is thrown, the function will attempt
to retrieve the associated error code and return it, otherwise it will return
error::exception.
! std::is_reference< T >::value
Strong guarantee.
|
Type |
Description |
|---|---|
|
|
The type to convert to. |
|
Name |
Description |
|---|---|
|
|
The |
jv converted to result<T>.
value_to_tag,
value_to,
value_from,
tag_invoke:
A general pattern for supporting customisable functions
Convenience header <boost/json.hpp>