map_category
Conversion category for maps.
Synopsis
Defined in header <boost/json/conversion.hpp>.
struct map_category;
Description
Maps are represented in JSON as objects. Such representation limits this category to 1-to-1 maps (as opposed to 1-to-many e.g. std::multimap) with string keys.
By default a type T is considered a map if given t, a glvalue of type T,
-
is_sequence_like<T>::valueistrue; and -
given type
Itdenotingdecltype(std::begin(t)), and typesKandM,std::iterator_traits<It>::value_typedenotesstd::pair<K, M>; and -
std::is_string_like<K>::valueistrue; and -
given
v, a glvalue of typeV, andE, the type denoted bydecltype(t.emplace(v)),std::is_tuple_like<E>::valueistrue.
|
The restriction for |
Users can specialize conversion_category_for for their own types if they want them to be treated like maps. For example:
namespace boost {
namespace json {
template <>
struct conversion_category_for<your::map>
{
using type = map_category;
};
} // namespace boost
} // namespace json
Matching Types
Convenience header <boost/json.hpp>.