
Hi,
After fixing header include orders for the umpteenth time to ensure boost/serialization/shared_ptr.hpp is included before shared_ptr.hpp so it can do it's #define private public hack I wondered if this was any closer to an acceptable resolution? I know this is brought up periodcally but it really needs to be sorted out in someway
I fully agree. Not only does the private-public hack bother me, but also the fact that a special export macro BOOST_SHARED_POINTER_EXPORT is needed to export classes used with shared_ptr. It's especially cumbersome when shared_ptr is used polymorphically, i.e. we use shared_ptr<Base> that actually points to an instance of class Derived. Also, if I'm not mistaken, the current scheme does not support weak_ptr. Since shared_ptr is such an important and often used class (at least at my company; we use it almost exclusively instead of raw pointers) , there should be proper, built-in support in boost::serialization for it. No extra macro or intrusive hack to shared_ptr should be required in order to be able to use it. As was discussed before, a good way to achieve this is to use a pointer-to-shared_ptr map in the input archive when loading archives that contain shared_ptrs. This is actually the approach that we've hacked into the version of boost::serialization here at work. We've been using it for a couple of months now like this and have not experienced any problems with it. And it also works for serializing weak_ptr. However, I would really appreciate an 'official' solution to shared_ptr (and weak_ptr) serialization. Best Regards, Martin TAB Austria Haiderstraße 40 4052 Ansfelden Austria Phone: +43 7229 78040-218 Fax: +43 7229 78040-209 E-mail: martin.ecker@tab.at http://www.tab.at