Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57985 - in trunk/libs/serialization: example vc7ide
From: ramey_at_[hidden]
Date: 2009-11-27 17:17:03


Author: ramey
Date: 2009-11-27 17:17:03 EST (Fri, 27 Nov 2009)
New Revision: 57985
URL: http://svn.boost.org/trac/boost/changeset/57985

Log:
tweaked demo_polymorphic example
Text files modified:
   trunk/libs/serialization/example/demo_polymorphic_A.cpp | 25 ++++++++++++-------------
   trunk/libs/serialization/example/demo_polymorphic_A.hpp | 9 +++++++--
   trunk/libs/serialization/vc7ide/demo_polymorphic.vcproj | 3 +++
   3 files changed, 22 insertions(+), 15 deletions(-)

Modified: trunk/libs/serialization/example/demo_polymorphic_A.cpp
==============================================================================
--- trunk/libs/serialization/example/demo_polymorphic_A.cpp (original)
+++ trunk/libs/serialization/example/demo_polymorphic_A.cpp 2009-11-27 17:17:03 EST (Fri, 27 Nov 2009)
@@ -12,16 +12,15 @@
 
 #include "demo_polymorphic_A.hpp"
 
-// now we can define the serialization for class A
-void A::serialize(
- boost::archive::polymorphic_iarchive & ar,
- const unsigned int file_version
-){
- ar & data;
-}
-void A::serialize(
- boost::archive::polymorphic_oarchive & ar,
- const unsigned int file_version
-){
- ar & data;
-}
+// explicitly instantiate templates for polymorphic archives
+// used by this demo.
+template
+void A::serialize<boost::archive::polymorphic_iarchive>(
+ boost::archive::polymorphic_iarchive &,
+ const unsigned int
+);
+template
+void A::serialize<boost::archive::polymorphic_oarchive>(
+ boost::archive::polymorphic_oarchive &,
+ const unsigned int
+);

Modified: trunk/libs/serialization/example/demo_polymorphic_A.hpp
==============================================================================
--- trunk/libs/serialization/example/demo_polymorphic_A.hpp (original)
+++ trunk/libs/serialization/example/demo_polymorphic_A.hpp 2009-11-27 17:17:03 EST (Fri, 27 Nov 2009)
@@ -20,8 +20,13 @@
 
 struct A {
     // class a contains a pointer to a "hidden" declaration
- void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version);
- void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version);
+ template<class Archive>
+ void serialize(
+ Archive & ar,
+ const unsigned int file_version
+ ){
+ ar & data;
+ }
     int data;
     bool operator==(const A & rhs) const {
         return data == rhs.data;

Modified: trunk/libs/serialization/vc7ide/demo_polymorphic.vcproj
==============================================================================
--- trunk/libs/serialization/vc7ide/demo_polymorphic.vcproj (original)
+++ trunk/libs/serialization/vc7ide/demo_polymorphic.vcproj 2009-11-27 17:17:03 EST (Fri, 27 Nov 2009)
@@ -130,6 +130,9 @@
                         RelativePath="..\example\demo_polymorphic.cpp">
                 </File>
                 <File
+ RelativePath="..\example\demo_polymorphic_A.cpp">
+ </File>
+ <File
                         RelativePath="..\example\demo_polymorphic_A.hpp">
                 </File>
         </Files>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk