optional_category

Conversion category for optionals.

Synopsis

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

using optional_category = std::integral_constant< conversion_category, conversion_category::optional >;

Description

Optionals are represented in JSON as null if not engaged (i.e. does not store a value), or as the stored type otherwise.

By default a type T is considered an optional if

  • given t, a glvalue of type T, decltype( t.value() ) is well-formed and isn’t a void type; and

  • t.reset() is well-formed;

Users can specialize conversion_category_of for their own types if they want them to be treated as optionals. For example:

namespace boost { namespace json {

template <>
struct conversion_category_of<your::optional> : optional_category
{ };

} }

Matching Types

Convenience header <boost/json.hpp>.