is_variant_like

Determine if T should be treated as a variant.

Synopsis

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

template<
    class T>
struct is_variant_like;

This trait is deprecated and will be removed in Boost 1.92.0. Switch to using conversion_category_for and variant_category.

Variants are serialised the same way their active alternative is serialised. The opposite conversion selects the first alternative for which conversion succeeds.

Given t, a glvalue of type const T, if t.valueless_by_exception() is well-formed, then the trait provides the member constant value that is equal to true. Otherwise, value is equal to false.

Users can specialize the trait for their own types if they don’t want them to be treated as variants. For example:

namespace boost {
namespace json {

template <>
struct is_variant_like<your::variant> : std::false_type
{ };

} // namespace boost
} // namespace json

Types Satisfying the Trait

Convenience header <boost/json.hpp>.