## `result_for`

Helper trait that returns `boost::system::result`.

### Synopsis

Defined in header <boost/json/result_for.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 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>
        boost::json::result_for<my_class, JsonValue>
        tag_invoke(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>.

Edit this page