I'm trying to investigate MsgPack's source code. In the example there's a fragment:
std::vector<std::string> vec;
vec.push_back("MessagePack");
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, vec);
I see in /usr/include/msgpack/object.hpp that an Object to be packed must have method msgpack_pack:
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
{
return detail::packer_serializer<Stream, T>::pack(o, v);
}
namespace detail {
template <typename Stream, typename T>
struct packer_serializer {
static packer<Stream>& pack(packer<Stream>& o, const T& v) {
v.msgpack_pack(o);
return o;
}
};
}
So I can't understand how compiler allows passing std::vector to msgpack::pack.