Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

result_for

Helper trait that returns result.

Synopsis

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

template<
    class T1,
    class T2>
struct result_for
Description

The primary template is an incomplete type. The library provides a partial specialisation result_for<T1, value>, that has nested type alias type that aliases the type result<T1>. The purpose of this trait is to let users provide non-throwing conversions for their types without creating a physical dependency on Boost.Json. For example:

namespace [link json.ref.boost `boost`]
{
namespace json
{

template < class T>
struct value_to_tag;

template < class T1, class T2>
struct result_for;
}
}

namespace mine
{
    class my_class;
    ...
    template < class JsonValue>
    [link json.ref.boost__json__result_for `boost::json::result_for<my_class, JsonValue>`]
    tag_invoke([link json.ref.boost__json__try_value_to_tag `boost::json::try_value_to_tag<my_class>`], const JsonValue& jv)
    { ... }
}
See Also

try_value_to, try_value_to_tag

Convenience header <boost/json.hpp>


PrevUpHomeNext