You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int main()
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);
// send the buffer ...
buffer.seekg(0);
// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());
msgpack::object_handle oh =
msgpack::unpack(str.data(), str.size());
// deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack::object deserialized = oh.get();
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(dst);
// or create the new instance
msgpack::type::tuple<int, bool, std::string> dst2 =
deserialized.as<msgpack::type::tuple<int, bool, std::string> >();
return 0;
}`
The text was updated successfully, but these errors were encountered:
第一次尝试用msgpack,是否有人遇到过编译测试demo时的头文件重定义错误:
msgpack\include\msgpack/v1/adaptor/int.hpp(153): error C2766: 显式专用化;已定义“msgpack::v1::adaptor::convert<wchar_t,void>”
msgpack\include\msgpack/v1/adaptor/int.hpp(107): note: 参见“convert<unsigned short,void>”的前一个定义
测试demo如下:
`#include <msgpack.hpp>
#include
#include
#include
int main()
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
}`
The text was updated successfully, but these errors were encountered: