map_category
Conversion category for maps.
Synopsis
Defined in header <boost/json/conversion.hpp>.
using map_category = std::integral_constant< conversion_category, conversion_category::map >;
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 typeT; and -
given
It, the type denoted bydecltype(std::begin(t)),std::iterator_traits<It>::iterator_categoryis well-formed and denotes a type; and -
decltype(std::end(t))also denotes the typeIt; and -
std::iterator_traits<It>::value_typeis notT; and -
given types
KandM,std::iterator_traits<It>::value_typedenotesstd::pair<K, M>; and -
conversion_category_of<K>::valueisconversion_category::string; and -
given
v, a value of typestd::iterator_traits<It>::value_type,std::tuple_size< decltype(t.emplace(v)) >::valueis a positive number.
Less formally, T should be a sequence of std::pairs with unique string-like keys.
|
The restriction for |
Users can specialize conversion_category_of for their own types if they want them to be treated like maps. For example:
namespace boost { namespace json {
template <>
struct is_map_like<your::map> : map_category
{ };
} }
Matching Types
Convenience header <boost/json.hpp>.