is_described_class

Determine if T should be treated as a described class.

Synopsis

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

template<
    class T>
struct is_described_class;

Description

Described classes are serialised as objects with an element for each described data member. Described bases are serialized in a flattened way, that is members of bases are serialized as direct elements of the object, and no nested objects are created for bases.

A described class should not have non-public described members (including inherited members) or non-public non-empty described bases. Or more formally, given L, a class template of the form template<class...> struct L {}, if

  • boost::describe::has_describe_members<T>::value is true; and

  • boost::describe::describe_members<T, boost::describe::mod_private | boost::describe::mod_protected | boost::describe::mod_inherited> denotes L<>; and

  • std::is_union<T>::value is false;

then the trait provides the member constant value that is equal to true. Otherwise, value is equal to false.

Shadowed members are ignored both for requirements checking and for performing conversions.

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

namespace boost {
namespace json {

template <>
struct is_described_class<your::described_class> : std::false_type
{ };

} // namespace boost
} // namespace json

Users can also specialize the trait for their own types with described non-public data members to enable this conversion implementation. Note that non-public bases are not supported regardless.

See Also

Convenience header <boost/json.hpp>.