I would like to send the following struct over msgpack.
struct MyStruct {
std::string name{""};
int* val{nullptr};
MSGPACK_DEFINE( name, val );
};
Thus far in all of my projects, the only way I've streamed with msgpack is using MSGPACK_DEFINE, then writing the struct to msgpack::sbuffer (and sending it). the MSGPACK_DEFINE macro complains that that perhaps I missed the "->" so I'm guessing it doesn't detect that it's a pointer.
Smart pointers seem to work though:
struct MyStruct {
std::string name{""};
std::shared_ptr<int> val{nullptr};
MSGPACK_DEFINE( name, val );
};
The caveat is that the receiver on the other end needs val to be a raw pointer. I would like to do this without converting on the receiving side. Any ideas?