$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r52109 - branches/release/boost/serialization
From: ramey_at_[hidden]
Date: 2009-04-01 12:02:33
Author: ramey
Date: 2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
New Revision: 52109
URL: http://svn.boost.org/trac/boost/changeset/52109
Log:
Merge changes from trunk to release
Text files modified: 
   branches/release/boost/serialization/array.hpp              |     3                                         
   branches/release/boost/serialization/export.hpp             |    13 ++-                                     
   branches/release/boost/serialization/extended_type_info.hpp |     5                                         
   branches/release/boost/serialization/static_warning.hpp     |     4                                         
   branches/release/boost/serialization/variant.hpp            |    10 +-                                      
   branches/release/boost/serialization/void_cast.hpp          |   124 +++++++++++++++++++++++++++++++-------- 
   6 files changed, 115 insertions(+), 44 deletions(-)
Modified: branches/release/boost/serialization/array.hpp
==============================================================================
--- branches/release/boost/serialization/array.hpp	(original)
+++ branches/release/boost/serialization/array.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -106,7 +106,6 @@
       return m_element_count;
     }
     
-    
 private:
     value_type* m_t;
     std::size_t const m_element_count;
@@ -121,9 +120,7 @@
     return array<T>(t, s);
 }
 
-
 template <class Archive, class T, std::size_t N>
-
 void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version */)
 {
   ar & boost::serialization::make_nvp("elems",a.elems);
Modified: branches/release/boost/serialization/export.hpp
==============================================================================
--- branches/release/boost/serialization/export.hpp	(original)
+++ branches/release/boost/serialization/export.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -86,7 +86,7 @@
 template <class Archive, class Serializable>
 struct ptr_serialization_support
 {
-# if defined(BOOST_MSVC)
+# if defined(BOOST_MSVC) || defined(__SUNPRO_CC)
     virtual BOOST_DLLEXPORT void instantiate() BOOST_USED;
 # elif defined(__BORLANDC__)   
     static BOOST_DLLEXPORT void instantiate() BOOST_USED;
@@ -118,6 +118,8 @@
     );
 }
 
+namespace {
+
 template<class T>
 struct guid_initializer
 {  
@@ -149,6 +151,7 @@
 template<typename T>
 struct init_guid;
 
+} // anonymous
 } // namespace detail
 } // namespace archive
 } // namespace boost
@@ -157,17 +160,18 @@
     namespace boost {                                                  \
     namespace archive {                                                \
     namespace detail {                                                 \
+    namespace {                                                        \
     template<>                                                         \
     struct init_guid< T > {                                            \
         static ::boost::archive::detail::guid_initializer< T > const   \
             & guid_initializer;                                        \
     };                                                                 \
-    }}}                                                                \
     ::boost::archive::detail::guid_initializer< T > const &            \
         ::boost::archive::detail::init_guid< T >::guid_initializer =   \
            ::boost::serialization::singleton<                          \
                ::boost::archive::detail::guid_initializer< T >         \
            >::get_mutable_instance().export_guid(K);                   \
+    }}}}                                                                \
 /**/
 
 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
@@ -178,10 +182,9 @@
 // relationships for exported classes.  On all other compilers, use of
 // this macro is entirely optional.
 # define BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED(Base,Derived)                  \
-namespace                                                                           \
-{                                                                                   \
+namespace {                                                                         \
   static int BOOST_PP_CAT(boost_serialization_mwerks_init_, __LINE__) =             \
-      (::boost::archive::detail::instantiate_ptr_serialization((Derived*)0,0), 3);  \
+  (::boost::archive::detail::instantiate_ptr_serialization((Derived*)0,0), 3);      \
   static int BOOST_PP_CAT(boost_serialization_mwerks_init2_, __LINE__) = (          \
       ::boost::serialization::void_cast_register((Derived*)0,(Base*)0)              \
     , 3);                                                                           \
Modified: branches/release/boost/serialization/extended_type_info.hpp
==============================================================================
--- branches/release/boost/serialization/extended_type_info.hpp	(original)
+++ branches/release/boost/serialization/extended_type_info.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -22,6 +22,7 @@
 #include <cassert>
 #include <cstddef> // NULL
 #include <boost/config.hpp>
+#include <boost/noncopyable.hpp>
 #include <boost/serialization/config.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
@@ -34,8 +35,8 @@
 
 namespace boost { 
 namespace serialization {
-
-class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info
+class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info :
+    private boost::noncopyable
 {
 private: 
     // used to uniquely identify the type of class derived from this one
Modified: branches/release/boost/serialization/static_warning.hpp
==============================================================================
--- branches/release/boost/serialization/static_warning.hpp	(original)
+++ branches/release/boost/serialization/static_warning.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -162,12 +162,12 @@
      // VC6; __LINE__ macro broken when -ZI is used see Q199057, so 
      // non-conforming workaround is used.
 #    define BOOST_STATIC_WARNING_IMPL(B)                       \
-     struct {                                                  \
+     struct BOOST_JOIN(STATIC_WARNING, __LINE__) {             \
         struct S {                                             \
             typedef boost::serialization::static_warning_impl<(bool)( B )> f; \
             friend class f::STATIC_WARNING;                    \
         };                                                     \
-     }                                                         \
+     };                                                        \
      /**/
 #elif defined(BOOST_HAS_DESCRIPTIVE_INCOMPLETE_TYPE_WARNING)
 #    define BOOST_STATIC_WARNING_IMPL(B)                     \
Modified: branches/release/boost/serialization/variant.hpp
==============================================================================
--- branches/release/boost/serialization/variant.hpp	(original)
+++ branches/release/boost/serialization/variant.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -81,7 +81,7 @@
             Archive & /*ar*/,
             int /*which*/,
             V & /*v*/,
-            unsigned int /*version*/
+            const unsigned int /*version*/
         ){}
     };
 
@@ -91,7 +91,7 @@
             Archive & ar,
             int which,
             V & v,
-            unsigned int version
+            const unsigned int version
         ){
             if(which == 0){
                 // note: A non-intrusive implementation (such as this one)
@@ -115,7 +115,7 @@
         Archive & ar,
         int which,
         V & v,
-        unsigned int version
+        const unsigned int version
     ){
         typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<mpl::empty<S>,
             mpl::identity<load_null>,
@@ -130,7 +130,7 @@
 void load(
     Archive & ar, 
     boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>& v,
-    unsigned int version
+    const unsigned int version
 ){
     int which;
     typedef BOOST_DEDUCED_TYPENAME boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
@@ -149,7 +149,7 @@
 inline void serialize(
     Archive & ar,
     boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> & v,
-    unsigned int file_version
+    const unsigned int file_version
 ){
     split_free(ar,v,file_version);
 }
Modified: branches/release/boost/serialization/void_cast.hpp
==============================================================================
--- branches/release/boost/serialization/void_cast.hpp	(original)
+++ branches/release/boost/serialization/void_cast.hpp	2009-04-01 12:02:32 EDT (Wed, 01 Apr 2009)
@@ -17,12 +17,14 @@
 
 //  See http://www.boost.org for updates, documentation, and revision history.
 
+#include <cstddef> // for ptrdiff_t
+#include <boost/serialization/config.hpp>
 #include <boost/serialization/smart_cast.hpp>
 #include <boost/serialization/singleton.hpp>
 #include <boost/serialization/force_include.hpp>
 #include <boost/serialization/type_info_implementation.hpp>
-#include <boost/serialization/config.hpp>
-#include <boost/serialization/force_include.hpp>
+#include <boost/type_traits/is_virtual_base_of.hpp>
+
 #include <boost/config/abi_prefix.hpp> // must be the last header
 
 #ifdef BOOST_MSVC
@@ -84,7 +86,6 @@
 
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) void_caster
 {
-    friend struct void_caster_compare ;
     friend 
     BOOST_SERIALIZATION_DECL(void const *)
     boost::serialization::void_upcast(
@@ -99,27 +100,43 @@
         extended_type_info const & base,
         void const * const
     );
-    // Data members
-    const extended_type_info & m_derived;
-    const extended_type_info & m_base;
-    // each derived class must re-implement these;
-    virtual void const * upcast(void const * const t) const = 0;
-    virtual void const * downcast(void const * const t) const = 0;
     // cw 8.3 requires this!!
     void_caster& operator=(void_caster const &);
 protected:
-    void
-    static_register() const;
-    void
-    static_unregister() const;
+    void recursive_register(bool includes_virtual_base = false) const;
+    void recursive_unregister() const;
 public:
+    // Data members
+    const extended_type_info * m_derived;
+    const extended_type_info * m_base;
+    const std::ptrdiff_t m_difference;
+    virtual bool is_shortcut() const {
+        return false;
+    }
+    // note that void_casters are keyed on value of
+    // addresses to member extended type info records
+    bool operator<(const void_caster & lhs) const {
+        if(m_derived < lhs.m_derived)
+            return true;
+        if(m_derived == lhs.m_derived)
+            if(m_base < lhs.m_base)
+                return true;
+        return false;
+    }
+    // each derived class must re-implement these;
+    virtual void const * upcast(void const * const t) const = 0;
+    virtual void const * downcast(void const * const t) const = 0;
     // Constructor
     void_caster(
-        extended_type_info const & derived,
-        extended_type_info const & base
-    );
-    virtual ~void_caster(){};
-    bool operator==(const void_caster & rhs) const;
+        extended_type_info const * derived,
+        extended_type_info const * base,
+        std::ptrdiff_t difference = 0
+    ) :
+        m_derived(derived),
+        m_base(base),
+        m_difference(difference)
+    {}
+    virtual ~void_caster(){}
 };
 
 template <class Derived, class Base>
@@ -141,23 +158,68 @@
         return b;
     }
 public:
-    BOOST_DLLEXPORT void_caster_primitive() BOOST_USED;
+    void_caster_primitive();
     ~void_caster_primitive();
 };
 
 template <class Derived, class Base>
-BOOST_DLLEXPORT void_caster_primitive<Derived, Base>::void_caster_primitive() :
+void_caster_primitive<Derived, Base>::void_caster_primitive() :
     void_caster( 
-        type_info_implementation<Derived>::type::get_const_instance(), 
-        type_info_implementation<Base>::type::get_const_instance()
+        & type_info_implementation<Derived>::type::get_const_instance(), 
+        & type_info_implementation<Base>::type::get_const_instance(),
+        // note:I wanted to display from 0 here, but at least one compiler
+        // treated 0 by not shifting it at all.
+        reinterpret_cast<std::ptrdiff_t>(
+            static_cast<Derived *>(
+                reinterpret_cast<Base *>(1)
+            )
+        ) - 1
     )
 {
-    static_register();
+    recursive_register();
 }
 
 template <class Derived, class Base>
 void_caster_primitive<Derived, Base>::~void_caster_primitive(){
-    static_unregister();
+    recursive_unregister();
+}
+
+template <class Derived, class Base>
+class void_caster_virtual_base : 
+    public void_caster
+{
+public:
+    virtual void const * downcast(void const * const t) const {
+        const Derived * d = 
+            dynamic_cast<const Derived *>(
+                static_cast<const Base *>(t)
+            );
+        return d;
+    }
+    virtual void const * upcast(void const * const t) const {
+        const Base * b = 
+            dynamic_cast<const Base *>(
+                static_cast<const Derived *>(t)
+            );
+        return b;
+    }
+    void_caster_virtual_base();
+    ~void_caster_virtual_base();
+};
+
+template <class Derived, class Base>
+void_caster_virtual_base<Derived,Base>::void_caster_virtual_base() :
+    void_caster( 
+        & type_info_implementation<Derived>::type::get_const_instance(), 
+        & type_info_implementation<Base>::type::get_const_instance()
+    )
+{
+    recursive_register(true);
+}
+
+template <class Derived, class Base>
+void_caster_virtual_base<Derived,Base>::~void_caster_virtual_base(){
+    recursive_unregister();
 }
 
 } // void_cast_detail 
@@ -179,9 +241,17 @@
     Derived const * /* dnull = NULL */, 
     Base const * /* bnull = NULL */
 ){
-    return singleton<void_cast_detail::void_caster_primitive<
-        Derived, Base
-    > >::get_const_instance();
+    typedef
+        BOOST_DEDUCED_TYPENAME mpl::eval_if<boost::is_virtual_base_of<Base,Derived>,
+            mpl::identity<
+                void_cast_detail::void_caster_virtual_base<Derived, Base>
+            >
+        ,// else
+            mpl::identity<
+                void_cast_detail::void_caster_primitive<Derived, Base>
+            >
+        >::type typex;
+    return singleton<typex>::get_const_instance();
 }
 
 } // namespace serialization