Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Object reference tracking on instances bug?
From: Raoul Wols (r_at_[hidden])
Date: 2017-02-03 18:46:26


Can you give an example of the expected XML output and the actual XML output?

What is MyColorsObject?

Can you provide a complete minimal example?

--Raoul

> Op 3 feb. 2017 om 17:27 heeft Robert P <robert.pel.83_at_[hidden]> het volgende geschreven:
>
> In my serialize function I am exporting a class which is a template wrapper around std:vector.
>
> template <typename E>
> class MyArray
> {
> public:
> vector<E> array;
> ...
>
> template <typename Archive>
> void MyArray::serialize(Archive & ar, const unsigned int version)
> {
> ar & BOOST_SERIALIZATION_NVP(array);
> }
>
> }
>
> When I add unique class instance variables to this array and then serialize it to XML...
> ...
> MyArray<Color> colorsArray;
>
> Color a;
> a.name = "one";
> colorsArray.add(a);
>
> Color b;
> b.name = "two";
> colorsArray.add(b);
> ...
>
>
> template <typename Archive>
> void MyColorsObject::serialize(Archive & ar, const unsigned int version)
> {
> ar & BOOST_SERIALIZATION_NVP(colorsArray);
> }
>
> Sometimes the XML comes out using object_id_reference instead of the unique values, and this then gets improperly unserialized with incorrect values, i.e. both colors will have "one" as the name.
>
> I was able to disable object tracking and it works now, but I don't think it should be doing object reference tracking on instance variables. Is it because of the template wrapper around vector?
> _______________________________________________
> 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