Archive * This() and the most derived class.

Robert, A comment in interface_oarchive.hpp states that interface_oarchive<Archive>::This() is supposed to return the a pointer to the most derived class. Actually, it gives you a pointer to the "Archive" template parameter which may or may not be the most derived class, depending on how your internal "invoke" plumbing resolves the type. In the following case I was able to get the most derived class only by overriding both operator<<(const T & t) and save_override()(using VC2k3): class fau_xml_woarchive : public boost::archive::xml_woarchive { public: [...] template<class T> void save_override(const ::boost::serialization::nvp<T> & t, int i) { save_start(t.name()); boost::archive::save(*this, t.value()); save_end(t.name()); } template<class T> _Mytype& operator<<(const T & t) { save_override(t, 0); return *this; } [...] }; Was that your intention? Regards, George.

Robert, Sorry, I just saw your other comment about not deriving from boost::archive::xml_woarchive. :-) If only all problems were resolved so easily. Regards, George. "George M. Garner Jr." <gmgarner@erols.com> escreveu na mensagem news:d3gg2n$h3e$1@sea.gmane.org...
Robert,
A comment in interface_oarchive.hpp states that interface_oarchive<Archive>::This() is supposed to return the a pointer to the most derived class. Actually, it gives you a pointer to the "Archive" template parameter which may or may not be the most derived class, depending on how your internal "invoke" plumbing resolves the type. In the following case I was able to get the most derived class only by overriding both operator<<(const T & t) and save_override()(using VC2k3):
class fau_xml_woarchive : public boost::archive::xml_woarchive { public: [...] template<class T> void save_override(const ::boost::serialization::nvp<T> & t, int i) { save_start(t.name()); boost::archive::save(*this, t.value()); save_end(t.name()); } template<class T> _Mytype& operator<<(const T & t) { save_override(t, 0); return *this; } [...] };
Was that your intention?
Regards,
George.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (1)
-
George M. Garner Jr.