Boost logo

Boost Users :

From: Anders Sundman (anders.sundman_at_[hidden])
Date: 2007-02-02 04:49:37


You're right.. it should.

Thanks!

// Anders Sundman

Pranckevicius, Tadas skrev:
> I have just noticed, shouldn't it be
>
> ~Dyn() { delete [] data; }
>
>
> -----Original Message-----
> From: Anders Sundman [mailto:anders.sundman_at_[hidden]]
> Sent: 01 February 2007 14:55
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Serialization of dynamic data
>
> Hi!
>
> About the boost::serialization library, what is the best way to handle
> dynamic data in classes? Any idéas, suggestions or caveats? I didn't
> manage to find anything about this in the docs.
>
> Consider the following sample class:
>
> struct Dyn {
> Dyn(int s) : data(0), size(s) {
> data = new char[size];
> }
>
> ~Dyn() { delete data; }
>
> char* data;
> int size;
>
> private:
> friend class boost::serialization::access;
> template< class Archive > void serialize( Archive &ar, unsigned int ver ) {
> // -> ar & data; What to do here?
> ar & size;
> }
> };
>
> What to do with the data pointer?
>
> Is there any way to determine (in the serialize function) if a
> serialization or "de-serialization" is taking place? And have different
> behaviours - either allocating a new char[x] or copying data to the archive?
>
> Is there any way to store dynamic data in an archive?
>
> Best regards,
> Anders Sundman
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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