Skip to content

v2_0_cpp_variant

Takatoshi Kondo edited this page Jan 10, 2017 · 5 revisions

variant type

What is this?

msgpack-c doesn't have boost::variant adaptor. But msgpack::type::variant can contain any msgpack types. It is implemented using boost::variant. There are two variant types. One is value based msgpack::type::variant, the other is reference based msgpack::type::variant_ref.

Type mapping

In common types msgpack::type::variant and msgpack::type::variant_ref

msgpack::type variant type
NIL msgpack::type::nil_t
BOOLEAN bool
POSITIVE_INTEGER uint64_t
NEGATIVE_INTEGER int64_t
FLOAT double

msgpack::type::variant

msgpack::type variant type
STR std::string
BIN std::vector
EXT msgpack::type::ext
ARRAY std::vector<msgpack::type::variant>
MAP std::multimap<msgpack::type::variant, msgpack::type::variant>

msgpack::type::variant_ref

msgpack::type variant type
STR boost::string_ref
BIN msgpack::type::raw_ref
EXT msgpack::type::ext_ref
ARRAY std::vector<msgpack::type::variant_ref>
MAP std::multimap<msgpack::type::variant, msgpack::type::variant_ref>