Boost logo

Boost Users :

From: Jens Theisen (jth01_at_[hidden])
Date: 2006-01-17 16:06:00


Joseph schrieb:
> In the meantime, I'm experiencing a much simpler problem. Although I
> can serialize classes of the form boost::shared_ptr<T>, where T is a
> class I've defined, I get compilation errors if I try to serialize a
> boost::shared_ptr<int>.

> How can I resolve this?

In such error messages, the first thing to look at is where the actual
error happens, indicated by gcc with "instantiated for here". You'll find
it's a static assertion and along with it the comment:

    // The most common cause of trapping here would be serializing
    // something like shared_ptr<int>. This occurs because int
    // is never tracked by default. Wrap int in a trackable type

As you can then look up in the documentation, for ints the address is not
serialised, as their tracking traits default to track_never, which is
probably sensible. Simply wrap you int in your own class, then you are
fine. And this is as efficient.

Jens


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net