Question

I'm pretty new to "msgpack". I'm trying to pack the user-defined class:

MyClass::Pack()
{
    msgpack::sbuffer sbuf;
    msgpack::pack(sbuf, this);
}

But compiler (VC 9.0) says me

error C2228: left of '.msgpack_pack' must have class/struct/union third_party\msgpack\include\msgpack\object.hpp 218

The only way I've found:

MyClass::Pack()
{
    MyClass copy(this);
    msgpack::sbuffer sbuf;
    msgpack::pack(sbuf, copy);
}

But what if I don't want to make a copy (e.g. it is heavy operation or requires many additional resources)? Can I do this without a copy ctor? Thanks.

Was it helpful?

Solution

The call msgpack::pack(sbuf, this); could be msgpack::pack(sbuf, *this); to get an object (this is just a pointer) ... and I'm not sure that MyClass copy(this); is calling a proper copy constructor... maybe I'm wrong, I did not use msgpack yet, I just see C++ :(

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top