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>::value
istrue
; and -
given type
It
denotingdecltype(std::begin(t))
, and typesK
andM
,std::iterator_traits<It>::value_type
denotesstd::pair<K, M>
; and -
std::is_string_like<K>::value
istrue
; and -
given
v
, a glvalue of typeV
, andE
, the type denoted bydecltype(t.emplace(v))
,std::is_tuple_like<E>::value
istrue
.
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>.