variant_category
Conversion category for variants.
Synopsis
Defined in header <boost/json/conversion.hpp>.
struct variant_category;
Description
Variants are serialised the same way their active alternative is serialised. The opposite conversion selects the first alternative for which conversion succeeds.
By default a type T
is considered a variant if given t
, a glvalue of type const T
, t.valueless_by_exception()
is well-formed.
Users can specialize conversion_category_for
for their own types if they want them to be treated as variants. For example:
namespace boost {
namespace json {
template <>
struct conversion_category_for<your::variant>
{
using type = variant_category;
};
} // namespace boost
} // namespace json
Mathcing Types
Convenience header <boost/json.hpp>.