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 the documentation for a snapshot of the master branch, built from commit 88fe07608e.
PrevUpHomeNext

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
Description

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

Convenience header <boost/json.hpp>


PrevUpHomeNext