Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59455 - trunk/boost/archive/detail
From: ramey_at_[hidden]
Date: 2010-02-03 16:33:22


Author: ramey
Date: 2010-02-03 16:33:20 EST (Wed, 03 Feb 2010)
New Revision: 59455
URL: http://svn.boost.org/trac/boost/changeset/59455

Log:
address const T * serialization
Text files modified:
   trunk/boost/archive/detail/check.hpp | 10 +++++-----
   trunk/boost/archive/detail/iserializer.hpp | 34 ++++++++++++++++++++--------------
   2 files changed, 25 insertions(+), 19 deletions(-)

Modified: trunk/boost/archive/detail/check.hpp
==============================================================================
--- trunk/boost/archive/detail/check.hpp (original)
+++ trunk/boost/archive/detail/check.hpp 2010-02-03 16:33:20 EST (Wed, 03 Feb 2010)
@@ -48,7 +48,7 @@
 // checks for objects
 
 template<class T>
-void inline check_object_level(){
+inline void check_object_level(){
     typedef
         BOOST_DEDUCED_TYPENAME mpl::greater_equal<
             serialization::implementation_level<T>,
@@ -61,7 +61,7 @@
 }
 
 template<class T>
-void inline check_object_versioning(){
+inline void check_object_versioning(){
     typedef
         BOOST_DEDUCED_TYPENAME mpl::or_<
             BOOST_DEDUCED_TYPENAME mpl::greater<
@@ -79,7 +79,7 @@
 }
 
 template<class T>
-void inline check_object_tracking(){
+inline void check_object_tracking(){
     // presume it has already been determined that
     // T is not a const
     BOOST_STATIC_ASSERT(! boost::is_const<T>::value);
@@ -101,7 +101,7 @@
 // checks for pointers
 
 template<class T>
-void inline check_pointer_level(){
+inline void check_pointer_level(){
     // we should only invoke this once we KNOW that T
     // has been used as a pointer!!
     typedef
@@ -149,7 +149,7 @@
 }
 
 template<class T>
-void inline check_const_loading(){
+inline void check_const_loading(){
     typedef
         BOOST_DEDUCED_TYPENAME mpl::or_<
             BOOST_DEDUCED_TYPENAME boost::serialization::is_wrapper<T>,

Modified: trunk/boost/archive/detail/iserializer.hpp
==============================================================================
--- trunk/boost/archive/detail/iserializer.hpp (original)
+++ trunk/boost/archive/detail/iserializer.hpp 2010-02-03 16:33:20 EST (Wed, 03 Feb 2010)
@@ -455,7 +455,7 @@
     };
 
     template<class T>
- static const basic_pointer_iserializer * register_type(Archive &ar, T & /*t*/){
+ static const basic_pointer_iserializer * register_type(Archive &ar, const T & /*t*/){
         // there should never be any need to load an abstract polymorphic
         // class pointer. Inhibiting code generation for this
         // permits abstract base classes to be used - note: exception
@@ -472,30 +472,32 @@
     template<class T>
     static T * pointer_tweak(
         const boost::serialization::extended_type_info & eti,
- void * t,
- T &
+ void const * const t,
+ const T &
     ) {
         // tweak the pointer back to the base class
         return static_cast<T *>(
- boost::serialization::void_upcast(
- eti,
- boost::serialization::singleton<
- BOOST_DEDUCED_TYPENAME
- boost::serialization::type_info_implementation<T>::type
- >::get_const_instance(),
- t
+ const_cast<void *>(
+ boost::serialization::void_upcast(
+ eti,
+ boost::serialization::singleton<
+ BOOST_DEDUCED_TYPENAME
+ boost::serialization::type_info_implementation<T>::type
+ >::get_const_instance(),
+ t
+ )
             )
         );
     }
 
     template<class T>
- static void load(Archive & /* ar */ , T & /* t */){
+ static void check_load(T & /* t */){
         check_pointer_level<T>();
         check_pointer_tracking<T>();
     }
 
     static const basic_pointer_iserializer *
- find(const boost::serialization::extended_type_info & type){
+ find(const boost::serialization::extended_type_info & type){
         return static_cast<const basic_pointer_iserializer *>(
             archive_serializer_map<Archive>::find(type)
         );
@@ -503,10 +505,14 @@
 
     template<class Tptr>
     static void invoke(Archive & ar, Tptr & t){
- load(ar, *t);
+ check_load(*t);
         const basic_pointer_iserializer * bpis_ptr = register_type(ar, *t);
         const basic_pointer_iserializer * newbpis_ptr = ar.load_pointer(
- * reinterpret_cast<void **>(&t),
+ // note major hack here !!!
+ // I tried every way to convert Tptr &t (where Tptr might
+ // include const) to void * &. This is the only way
+ // I could make it work. RR
+ (void * & )t,
             bpis_ptr,
             find
         );


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