[Boost-bugs] [Boost C++ Libraries] #7047: Deriving custom archive classes from boost::archive::text_oarchive_impl and boost::archive::text_iarchive_impl

Subject: [Boost-bugs] [Boost C++ Libraries] #7047: Deriving custom archive classes from boost::archive::text_oarchive_impl and boost::archive::text_iarchive_impl
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-06-29 05:31:07


#7047: Deriving custom archive classes from boost::archive::text_oarchive_impl and
boost::archive::text_iarchive_impl
--------------------------------------+-------------------------------------
 Reporter: zachais.vawter@… | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: |
--------------------------------------+-------------------------------------
 From here[http://stackoverflow.com/questions/10691911/deriving-custom-
 archive-classes-from-boostarchivetext-oarchive-impl-and-boos]

 Summary:
 After changing the base classes of my custom archives from
 binary_?archive_impl to text_?archive_impl, my custom archive classes are
 no longer "found" when the compiler is instantiating the serialize(...)
 methods in my other classes.

 Background:
 My application was successfully reading and writing files to disk using
 subclasses of binary_?archive_impl (the documentation and/or code comments
 recommend this over deriving from binary_?archive). I needed to switch
 from a binary file format to a text format, so I switched the base classes
 of my custom archives to text_?archive_impl. That's when everything blew
 up.

 The problem:
 My custom archive classes add functionality, including some additional
 methods which do not exist in their Boost base classes; these methods are
 called in the serialize(...) methods in many of my classes, and they were
 working fine. After changing the base classes from binary_?archive_impl to
 text_?archive_impl, I received compilation errors all over the place
 complaining that my custom methods do not exist in text_?archive. Well,
 that's obvious (!!!), but they do exist in my custom archives, and they
 were working just fine when I was using Boost's binary base classes.
 What's the deal?

 What I found, and my temporary - but undesirable - solution:
 After tearing my hair out and going around in circles for about a day,
 this is what I found...

 1) Some time ago (Boost 1.34 I believe), the files "binary_?archive.hpp"
 were split up into "binary_?archive_impl.hpp" and "binary_?archive.hpp"
 (the latter #include the former). This was not done to
 "text_?archive.hpp". (As a result, I changed my application's #include
 lines from "binary_?archive_impl.hpp" to simply "text_?archive.hpp".)

 2) If I split up "text_?archive.hpp" into two parts and #include only the
 "..._impl.hpp" headers, everything works. (But I really don't want to
 modify my Boost installation!)

 3) Looking more closely at these headers and fiddling around a bit, I
 found that if I use the original, unmodified headers and comment out the
 line

 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)

 (and likewise for text_iarchive), then everything works fine again. (By
 the way I have similar lines in my own archive code to "register" my
 custom archives.)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7047>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC