[serialization] and list<shared_ptr<const T> >

If I try and write a list<shared_ptr<const T> > to an archive, I get a compilation error. I'm guessing this is because the objects in the list are shared_ptr<const T> The documentation for const members says to use const_cast<T&>(t) but when you want to try and write a list, you can't do this unless you write all the objects manually. Is there a way for serialization to be able to handle the const implicitly (for containers at least)? Otherwise the only solutions I can see are - Don't use const objects - Write all elements of the list ourselves. Thanks Russell

"Russell Hind" <rh_gmane@mac.com> wrote in message news:clif1q$d6$1@sea.gmane.org...
Hmmm, maybe this cast should be in serialize/list.hpp ? Try adding this cast to your personal copy of serialization/list.hpp and see if that addresses the problem. Let me know if that does it. Robert Ramey

Robert Ramey wrote:
Should it not be in shared_ptr serialize method? The type is list<shared_ptr<const T> > You get the same problem with shared_ptr<const T> which can't be written. So if you have a member e.g. shared_ptr<const MyClass_c> m_MyClass; The the actual member isn't const, it is a shared_ptr, but the thing it points to is a const object so shouldn't shared_ptr serialize do a const_cast on its underlying pointer? If it were a const shared_ptr<T> then I agree that it should be in serialize/list.hpp (or probably an base header of this as the actual serialization doesn't seem to be done there) Thanks Russell
participants (2)
-
Robert Ramey
-
Russell Hind