Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-04-23 07:40:29


Author: matus.chochlik
Date: 2008-04-23 07:40:28 EDT (Wed, 23 Apr 2008)
New Revision: 44740
URL: http://svn.boost.org/trac/boost/changeset/44740

Log:
Fixed few things in cube.cpp to make it compilable with MSVC++ 2008
Text files modified:
   sandbox/mirror/libs/examples/serialization/cube.cpp | 60 +++++++++++++++++++++------------------
   1 files changed, 32 insertions(+), 28 deletions(-)

Modified: sandbox/mirror/libs/examples/serialization/cube.cpp
==============================================================================
--- sandbox/mirror/libs/examples/serialization/cube.cpp (original)
+++ sandbox/mirror/libs/examples/serialization/cube.cpp 2008-04-23 07:40:28 EDT (Wed, 23 Apr 2008)
@@ -271,12 +271,13 @@
                 // first load the previous
                 single_attrib_loader<meta_class, mpl::int_<position::value - 1> >(ar, c);
                 // query the value of the current member
- typename mpl::at<
+ typedef typename mpl::at<
                         typename meta_class::all_attributes::type_list,
                         position
- >::type value;
+ >::type member_type;
+ member_type value;
                 // load it
- typename to_be_loaded<Class>::type dst = value;
+ typename to_be_loaded<member_type>::type dst(value);
                 ar >> dst;
                 // and set it
                 meta_class::all_attributes::set(c, position(), value);
@@ -291,11 +292,12 @@
         {
                 typedef mpl::int_<0> position;
                 // we are on the first so just load it
- typename mpl::at<
+ typedef typename mpl::at<
                         typename meta_class::all_attributes::type_list,
                         position
- >::type value;
- typename to_be_loaded<Class>::type dst = value;
+ >::type member_type;
+ member_type value;
+ typename to_be_loaded<member_type>::type dst(value);
                 ar >> dst;
                 meta_class::all_attributes::set(c, position(), value);
         }
@@ -303,16 +305,13 @@
 
 
 template<class Archive, class Class>
-void load(Archive & ar, Class & c)
+void do_load(Archive & ar, Class & c)
 {
         typedef BOOST_MIRROR_REFLECT_CLASS(Class) meta_Class;
         typedef mpl::int_<meta_Class::all_attributes::size::value - 1> last;
         single_attrib_loader<meta_Class, last>(ar, c);
 }
 
-template<class Archive, class Class>
-void do_save(Archive & ar, Class & c);
-
 template <typename Type>
 struct to_be_saved
 {
@@ -323,21 +322,6 @@
>::type type;
         to_be_saved(Type& _inst):inst(_inst){ }
         Type& inst;
-
- friend class ::boost::serialization::access;
-
- template <class Archive>
- void save(Archive & ar, const unsigned int version) const
- {
- ::boost::mirror::do_save(ar, inst);
- }
-
- template <class Archive>
- void load(Archive & ar, const unsigned int version)
- {
- }
-
- BOOST_SERIALIZATION_SPLIT_MEMBER()
 };
 
 
@@ -356,7 +340,9 @@
>::type member_type;
                 member_type value;
                 // and save it
- typename to_be_saved<member_type>::type src(meta_class::all_attributes::query(c, position(), value));
+ typename to_be_saved<member_type>::type src(
+ meta_class::all_attributes::query(c, position(), value)
+ );
                 ar << src;
         }
 };
@@ -375,7 +361,9 @@
                         position
>::type member_type;
                 member_type value;
- typename to_be_saved<member_type>::type src(meta_class::all_attributes::query(c, position(), value));
+ typename to_be_saved<member_type>::type src(
+ meta_class::all_attributes::query(c, position(), value)
+ );
                 ar << src;
         }
 };
@@ -390,6 +378,22 @@
 
 
 } // namespace mirror
+namespace archive {
+
+template<class Archive, class Class>
+void save(Archive & ar, mirror::to_be_saved<Class> & c)
+{
+ mirror::do_save(ar, c.inst);
+}
+
+template<class Archive, class Class>
+void load(Archive & ar, mirror::to_be_loaded<Class> & c)
+{
+ mirror::do_load(ar, c.inst);
+}
+
+
+} // namespace archive
 } // namespace boost
 
 int main(void)
@@ -420,7 +424,7 @@
                 boost::archive::text_iarchive ia(in);
                 //
                 to_be_loaded<Cube> lc2(c2);
- //ia >> lc2;
+ ia >> lc2;
         }
         // compare them
         assert(c1 == c2);


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