Boost logo

Boost-Commit :

From: ramey_at_[hidden]
Date: 2008-03-18 00:58:53


Author: ramey
Date: 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
New Revision: 43690
URL: http://svn.boost.org/trac/boost/changeset/43690

Log:
Support serialization in DLLS
Make thread-safe
fix portable binary archives
Added:
   trunk/boost/serialization/factory.hpp (contents, props changed)
   trunk/boost/serialization/singleton.hpp (contents, props changed)
Text files modified:
   trunk/boost/serialization/base_object.hpp | 77 ++++++++++--------
   trunk/boost/serialization/binary_object.hpp | 2
   trunk/boost/serialization/collections_load_imp.hpp | 2
   trunk/boost/serialization/complex.hpp | 42 ++++-----
   trunk/boost/serialization/config.hpp | 66 ++++++++--------
   trunk/boost/serialization/ephemeral.hpp | 5
   trunk/boost/serialization/export.hpp | 105 ++++++++++++++------------
   trunk/boost/serialization/extended_type_info.hpp | 65 ++++++++-------
   trunk/boost/serialization/extended_type_info_no_rtti.hpp | 86 ++++++++++-----------
   trunk/boost/serialization/extended_type_info_typeid.hpp | 123 ++++++++++++++++--------------
   trunk/boost/serialization/force_include.hpp | 4 -
   trunk/boost/serialization/is_abstract.hpp | 2
   trunk/boost/serialization/optional.hpp | 3
   trunk/boost/serialization/type_info_implementation.hpp | 2
   trunk/boost/serialization/void_cast.hpp | 159 +++++++++++++++------------------------
   trunk/boost/serialization/void_cast_fwd.hpp | 2
   trunk/boost/serialization/weak_ptr.hpp | 4
   17 files changed, 367 insertions(+), 382 deletions(-)

Modified: trunk/boost/serialization/base_object.hpp
==============================================================================
--- trunk/boost/serialization/base_object.hpp (original)
+++ trunk/boost/serialization/base_object.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -25,12 +25,15 @@
 
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/int.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/identity.hpp>
+
 #include <boost/type_traits/is_base_and_derived.hpp>
 #include <boost/type_traits/is_pointer.hpp>
 #include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
 
 #include <boost/static_assert.hpp>
-#include <boost/serialization/type_info_implementation.hpp>
 #include <boost/serialization/force_include.hpp>
 #include <boost/serialization/void_cast_fwd.hpp>
 
@@ -39,40 +42,44 @@
 
 namespace detail
 {
-// only register void casts if the types are polymorphic
- template<class Base, class Derived>
- struct base_register
- {
- static void const* execute(mpl::false_) { return 0; }
-
- static void const* execute(mpl::true_)
- {
- return &void_cast_register((Derived const*)0, (Base const*)0);
- }
-
- static void const* invoke()
- {
- typedef mpl::bool_<
- type_info_implementation<Base>::type::is_polymorphic::value
- > is_polymorphic;
-
- return execute(is_polymorphic());
- }
- };
-
- // get the base type for a given derived type
- // preserving the const-ness
- template<class B, class D>
- struct base_cast
- {
- typedef BOOST_DEDUCED_TYPENAME
- mpl::if_<
- is_const<D>,
- const B,
- B
- >::type type;
- BOOST_STATIC_ASSERT(is_const<type>::value == is_const<D>::value);
- };
+ // get the base type for a given derived type
+ // preserving the const-ness
+ template<class B, class D>
+ struct base_cast
+ {
+ typedef BOOST_DEDUCED_TYPENAME
+ mpl::if_<
+ is_const<D>,
+ const B,
+ B
+ >::type type;
+ BOOST_STATIC_ASSERT(is_const<type>::value == is_const<D>::value);
+ };
+
+ // only register void casts if the types are polymorphic
+ template<class Base, class Derived>
+ struct base_register
+ {
+ struct polymorphic {
+ static void const * invoke(){
+ return &void_cast_register((Derived const*)0, (Base const*)0);
+ }
+ };
+ struct non_polymorphic {
+ static void const * invoke(){
+ return 0;
+ }
+ };
+ static void const * invoke(){
+ typedef BOOST_DEDUCED_TYPENAME mpl::eval_if<
+ is_polymorphic<Base>,
+ mpl::identity<polymorphic>,
+ mpl::identity<non_polymorphic>
+ >::type type;
+ return type::invoke();
+ }
+ };
+
 } // namespace detail
 
 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))

Modified: trunk/boost/serialization/binary_object.hpp
==============================================================================
--- trunk/boost/serialization/binary_object.hpp (original)
+++ trunk/boost/serialization/binary_object.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -76,8 +76,6 @@
  : public mpl::true_
 {};
 
-
-
 } // namespace serialization
 } // boost
 

Modified: trunk/boost/serialization/collections_load_imp.hpp
==============================================================================
--- trunk/boost/serialization/collections_load_imp.hpp (original)
+++ trunk/boost/serialization/collections_load_imp.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -26,8 +26,6 @@
 #include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
 
-#include <boost/aligned_storage.hpp>
-
 #include <boost/serialization/access.hpp>
 #include <boost/serialization/nvp.hpp>
 #include <boost/serialization/detail/stack_constructor.hpp>

Modified: trunk/boost/serialization/complex.hpp
==============================================================================
--- trunk/boost/serialization/complex.hpp (original)
+++ trunk/boost/serialization/complex.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -27,57 +27,53 @@
 namespace boost {
 namespace serialization {
 
-
 template<class Archive, class T>
 inline void serialize(
     Archive & ar,
     std::complex<T> & t,
     const unsigned int file_version
-)
-{
- boost::serialization::split_free(ar, t, file_version);
+){
+ boost::serialization::split_free(ar, t, file_version);
 }
 
 template<class Archive, class T>
 inline void save(
     Archive & ar,
- std::complex<T> const& x,
+ std::complex<T> const& t,
     const unsigned int /* file_version */
-)
-{
- double re=x.real();
- double im=x.imag();
- ar << boost::serialization::make_nvp("real", re);
- ar << boost::serialization::make_nvp("imag", im);
+){
+ const T re = t.real();
+ const T im = t.imag();
+ ar << boost::serialization::make_nvp("real", re);
+ ar << boost::serialization::make_nvp("imag", im);
 }
 
 template<class Archive, class T>
 inline void load(
     Archive & ar,
- std::complex<T>& x,
+ std::complex<T>& t,
     const unsigned int /* file_version */
-)
-{
- double re;
- double im;
- ar >> boost::serialization::make_nvp("real", re);
- ar >> boost::serialization::make_nvp("imag", im);
- x = std::complex<T>(re,im);
+){
+ T re;
+ T im;
+ ar >> boost::serialization::make_nvp("real", re);
+ ar >> boost::serialization::make_nvp("imag", im);
+ t = std::complex<T>(re,im);
 }
 
-/// specialization of serialization traits for complex
+// specialization of serialization traits for complex
 template <class T>
 struct is_bitwise_serializable<std::complex<T> >
- : public is_bitwise_serializable<T> {};
+ : public is_bitwise_serializable<T> {};
 
 template <class T>
 struct implementation_level<std::complex<T> >
- : mpl::int_<object_serializable> {} ;
+ : mpl::int_<object_serializable> {} ;
 
 // treat complex just like builtin arithmetic types for tracking
 template <class T>
 struct tracking_level<std::complex<T> >
- : mpl::int_<track_never> {} ;
+ : mpl::int_<track_never> {} ;
 
 } // serialization
 } // namespace boost

Modified: trunk/boost/serialization/config.hpp
==============================================================================
--- trunk/boost/serialization/config.hpp (original)
+++ trunk/boost/serialization/config.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -1,10 +1,4 @@
-#ifndef BOOST_SERIALIZATION_CONFIG_HPP
-#define BOOST_SERIALIZATION_CONFIG_HPP
-
-// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
+// note lack of include guards. This is intentional
 
 // config.hpp ---------------------------------------------//
 
@@ -28,22 +22,34 @@
 // the same library as BOOST_ARCHIVE. This could change some day in the
 // future
 
+// if BOOST_SERIALIZATION_DECL is defined undefine it now:
+#ifdef BOOST_SERIALIZATION_DECL
+ #undef BOOST_SERIALIZATION_DECL
+#endif
+
 #ifdef BOOST_HAS_DECLSPEC // defined in config system
 // we need to import/export our code only if the user has specifically
 // asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
 // libraries to be dynamically linked, or BOOST_SERIALIZATION_DYN_LINK
 // if they want just this one to be dynamically liked:
 #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
-#define BOOST_DYN_LINK
-// export if this is our own source, otherwise import:
-#if defined(BOOST_SERIALIZATION_SOURCE)
- #if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MWERKS__)
- #define BOOST_SERIALIZATION_DECL(T) __declspec(dllexport) T
- #else
- #define BOOST_SERIALIZATION_DECL(T) T __declspec(dllexport)
+ #if !defined(BOOST_DYN_LINK)
+ #define BOOST_DYN_LINK
     #endif
- #pragma message( "BOOST_SERIALIZATION_DECL __declspec(dllexport)" )
-#endif // defined(BOOST_SERIALIZATION_SOURCE)
+ // export if this is our own source, otherwise import:
+ #if defined(BOOST_SERIALIZATION_SOURCE)
+ #if defined(__BORLANDC__)
+ #define BOOST_SERIALIZATION_DECL(T) T __export
+ #else
+ #define BOOST_SERIALIZATION_DECL(T) __declspec(dllexport) T
+ #endif
+ #else
+ #if defined(__BORLANDC__)
+ #define BOOST_SERIALIZATION_DECL(T) T __import
+ #else
+ #define BOOST_SERIALIZATION_DECL(T) __declspec(dllimport) T
+ #endif
+ #endif // defined(BOOST_SERIALIZATION_SOURCE)
 #endif // defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK)
 #endif // BOOST_HAS_DECLSPEC
 
@@ -55,20 +61,16 @@
 // enable automatic library variant selection ------------------------------//
 
 #if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_SERIALIZATION_NO_LIB) \
-&& !defined(BOOST_SERIALIZATION_SOURCE) \
-&& !defined(BOOST_ARCHIVE_SOURCE) && !defined(BOOST_WARCHIVE_SOURCE)
-//
-// Set the name of our library, this will get undef'ed by auto_link.hpp
-// once it's done with it:
-//
-#define BOOST_LIB_NAME boost_serialization
-//
-// And include the header that does the work:
-//
-#include <boost/config/auto_link.hpp>
-
-#endif // !defined(BOOST_SERIALIZATION_SOURCE) && !defined(BOOST_ARCHIVE_SOURCE)
-
-//----------------------------------------------------------------------------//
+&& !defined(BOOST_ARCHIVE_SOURCE) && !defined(BOOST_WARCHIVE_SOURCE) \
+&& !defined(BOOST_SERIALIZATION_SOURCE)
+ //
+ // Set the name of our library, this will get undef'ed by auto_link.hpp
+ // once it's done with it:
+ //
+ #define BOOST_LIB_NAME boost_serialization
+ //
+ // And include the header that does the work:
+ //
+ #include <boost/config/auto_link.hpp>
 
-#endif // BOOST_SERIALIZATION_CONFIG_HPP
+#endif

Modified: trunk/boost/serialization/ephemeral.hpp
==============================================================================
--- trunk/boost/serialization/ephemeral.hpp (original)
+++ trunk/boost/serialization/ephemeral.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -1,7 +1,8 @@
 #ifndef BOOST_SERIALIZATION_EPHEMERAL_HPP
 #define BOOST_SERIALIZATION_EPHEMERAL_HPP
 
-// MS compatible compilers support #pragma once
+// MS compatible compilers support
+#pragma once
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma once
 #endif
@@ -9,7 +10,7 @@
 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
 // ephemeral_object.hpp: interface for serialization system.
 
-// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// (C) Copyright 2007 Matthias Troyer.
 // Use, modification and distribution is subject to the Boost Software
 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)

Modified: trunk/boost/serialization/export.hpp
==============================================================================
--- trunk/boost/serialization/export.hpp (original)
+++ trunk/boost/serialization/export.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -25,17 +25,23 @@
 
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/static_warning.hpp>
 #include <boost/preprocessor/stringize.hpp>
+#include <boost/type_traits/is_polymorphic.hpp>
 
-#include <boost/archive/detail/dynamically_initialized.hpp>
+#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
+ #include <boost/serialization/extended_type_info_typeid.hpp>
+#endif
 #include <boost/serialization/type_info_implementation.hpp>
 #include <boost/serialization/is_abstract.hpp>
 #include <boost/serialization/force_include.hpp>
+#include <boost/serialization/singleton.hpp>
 
 #include <boost/archive/detail/register_archive.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/mpl/and.hpp>
 #include <boost/mpl/not.hpp>
+#include <boost/mpl/bool.hpp>
 
 #include <iostream>
 
@@ -56,51 +62,21 @@
 {
     static const basic_pointer_iserializer &
     enable_load(mpl::true_){
- return pointer_iserializer<Archive, Serializable>::get_instance();
+ return boost::serialization::singleton<
+ pointer_iserializer<Archive, Serializable>
+ >::get_const_instance();
     }
 
     static const basic_pointer_oserializer &
     enable_save(mpl::true_){
- return pointer_oserializer<Archive, Serializable>::get_instance();
+ return boost::serialization::singleton<
+ pointer_oserializer<Archive, Serializable>
+ >::get_const_instance();
     }
-
     inline static void enable_load(mpl::false_) {}
     inline static void enable_save(mpl::false_) {}
 };
 
-template<class T>
-struct guid_initializer
-{
- typedef typename
- boost::serialization::type_info_implementation<T>::type eti_type;
-
- static void export_register(const char *key)
- {
- eti_type::export_register(key);
- }
-
- static const guid_initializer& get_instance(char const* key)
- {
- static guid_initializer const instance(key);
- return instance;
- }
-
- BOOST_DLLEXPORT guid_initializer(const char *key = 0) BOOST_USED ;
-};
-
-
-template<class T>
-BOOST_DLLEXPORT guid_initializer<T>::guid_initializer(const char *key)
-{
- if(0 != key)
- export_register(key);
-
- // generates the statically-initialized objects whose constructors
- // register the information allowing serialization of T objects
- // through pointers to their base classes.
- instantiate_ptr_serialization((T*)0, 0);
-}
-
 // On many platforms, naming a specialization of this template is
 // enough to cause its argument to be instantiated.
 template <void(*)()>
@@ -130,15 +106,43 @@
 template <class Archive, class Serializable>
 BOOST_DLLEXPORT void ptr_serialization_support<Archive,Serializable>::instantiate()
 {
- typedef mpl::not_<serialization::is_abstract<Serializable> > concrete;
-
     export_impl<Archive,Serializable>::enable_save(
- mpl::and_<concrete, BOOST_DEDUCED_TYPENAME Archive::is_saving>());
+ BOOST_DEDUCED_TYPENAME Archive::is_saving()
+ );
 
     export_impl<Archive,Serializable>::enable_load(
- mpl::and_<concrete, BOOST_DEDUCED_TYPENAME Archive::is_loading>());
+ BOOST_DEDUCED_TYPENAME Archive::is_loading()
+ );
 }
 
+template<class T>
+struct guid_initializer
+{
+ const guid_initializer & export_guid(char const* key, mpl::false_){
+ // generates the statically-initialized objects whose constructors
+ // register the information allowing serialization of T objects
+ // through pointers to their base classes.
+ instantiate_ptr_serialization((T*)0, 0);
+ return *this;
+ }
+ const guid_initializer & export_guid(char const* key, mpl::true_){
+ return *this;
+ }
+ const guid_initializer & export_guid(char const* key){
+ BOOST_STATIC_WARNING(boost::is_polymorphic<T>::value);
+ assert(NULL != key);
+ boost::serialization::singleton<
+ BOOST_DEDUCED_TYPENAME
+ boost::serialization::type_info_implementation<T>::type
+ >::get_mutable_instance().key_register(key);
+ // note: exporting an abstract base class will have no effect
+ // and cannot be used to instantitiate serialization code
+ // (one might be using this in a DLL to instantiate code)
+ //BOOST_STATIC_WARNING(! boost::is_abstract<T>::value);
+ return export_guid(key, serialization::is_abstract<T>());
+ }
+};
+
 } // namespace detail
 } // namespace archive
 } // namespace boost
@@ -146,9 +150,11 @@
 #define BOOST_CLASS_EXPORT_GUID(T, K) \
 namespace \
 { \
- ::boost::archive::detail::guid_initializer< T > const& \
+ ::boost::archive::detail::guid_initializer< T > const & \
         BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__) \
- = ::boost::archive::detail::guid_initializer< T >::get_instance(K); \
+ = ::boost::serialization::singleton< \
+ ::boost::archive::detail::guid_initializer< T > \
+ >::get_mutable_instance().export_guid(K); \
 }
 
 // the following is solely to support de-serialization of pointers serialized
@@ -156,9 +162,13 @@
 #define BOOST_CLASS_EXPORT_GUID_1(T, K) \
 namespace \
 { \
- ::boost::archive::detail::guid_initializer< T > const& \
- BOOST_PP_CAT(boost_serialization_guid_initializer_, __LINE__ ## _1) \
- = ::boost::archive::detail::guid_initializer< T >::get_instance(K); \
+ ::boost::archive::detail::guid_initializer< T > const & \
+ BOOST_PP_CAT( \
+ boost_serialization_guid_initializer_, \
+ BOOST_PP_CAT(__LINE__,_1) \
+ ) = ::boost::serialization::singleton< \
+ ::boost::archive::detail::guid_initializer< T > \
+ >::get_mutable_instance().export_guid(K); \
 }
 
 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
@@ -188,8 +198,7 @@
 // need to export it.
 #define BOOST_CLASS_EXPORT_CHECK(T) \
     BOOST_STATIC_WARNING( \
- boost::serialization::type_info_implementation< T > \
- ::type::is_polymorphic::value \
+ boost::is_polymorphic<U>::value \
     ); \
     /**/
 

Modified: trunk/boost/serialization/extended_type_info.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info.hpp (original)
+++ trunk/boost/serialization/extended_type_info.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -18,8 +18,9 @@
 
 // for now, extended type info is part of the serialization libraries
 // this could change in the future.
+#include <cstdarg>
+#include <cassert>
 #include <boost/config.hpp>
-#include <boost/noncopyable.hpp>
 #include <boost/serialization/config.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
@@ -33,53 +34,54 @@
 namespace boost {
 namespace serialization {
 
-class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info :
- private boost::noncopyable
+class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info
 {
-private:
- virtual bool
- less_than(const extended_type_info &rhs) const = 0;
- int type_info_key_cmp(const extended_type_info & rhs) const;
-
+private:
     // used to uniquely identify the type of class derived from this one
     // so that different derivations of this class can be simultaneously
     // included in implementation of sets and maps.
- const char * m_type_info_key;
- // flag to indicate wheter its been registered by type;
- bool m_self_registered;
- // flag to indicate wheter its been registered by type;
- bool m_key_registered;
- // flag indicating that no virtual function should be called here
- // this is necessary since it seems that at least one compiler (borland
- // and one version of gcc call less_than above when erasing even
- // when given an iterator argument.
- bool m_is_destructing;
+ const unsigned int m_type_info_key;
+ virtual bool
+ is_less_than(const extended_type_info &rhs) const {
+ assert(false);
+ return false;
+ };
+ virtual bool
+ is_equal(const extended_type_info &rhs) const {
+ assert(false);
+ return false;
+ };
+ void key_unregister();
 protected:
     const char * m_key;
- extended_type_info(const char * type_info_key);
+ // this class can't be used as is. It's just the
+ // common functionality for all type_info replacement
+ // systems. Hence, make these protected
+ extended_type_info(const unsigned int type_info_key = 0);
     // account for bogus gcc warning
     #if defined(__GNUC__)
     virtual
     #endif
     ~extended_type_info();
 public:
- void self_register();
- void key_register(const char *key);
- bool is_destructing() const {
- return m_is_destructing;
+ const char * get_key() const {
+ return m_key;
     }
+ void key_register(const char *key);
     bool operator<(const extended_type_info &rhs) const;
- bool operator==(const extended_type_info &rhs) const {
- return this == & rhs;
- }
+ bool operator==(const extended_type_info &rhs) const;
     bool operator!=(const extended_type_info &rhs) const {
- return this != & rhs;
- }
- const char * get_key() const {
- return m_key;
+ return !(operator==(rhs));
     }
     static const extended_type_info * find(const char *key);
- static const extended_type_info * find(const extended_type_info * t);
+ // for plugins
+ virtual void * construct(unsigned int count = 0, ...) const {
+ assert(false); // must be implemented if used
+ return NULL;
+ };
+ virtual void destroy(void const * const p) const {
+ assert(false); // must be implemented if used
+ }
 };
 
 } // namespace serialization
@@ -88,6 +90,7 @@
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
+
 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
 
 #endif // BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_HPP

Modified: trunk/boost/serialization/extended_type_info_no_rtti.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info_no_rtti.hpp (original)
+++ trunk/boost/serialization/extended_type_info_no_rtti.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -1,5 +1,6 @@
 #ifndef BOOST_EXTENDED_TYPE_INFO_NO_RTTI_HPP
 #define BOOST_EXTENDED_TYPE_INFO_NO_RTTI_HPP
+
 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
 // MS compatible compilers support #pragma once
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -17,12 +18,13 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 #include <cassert>
+
 #include <boost/config.hpp>
 #include <boost/static_assert.hpp>
-#include <boost/type_traits/is_const.hpp>
 
+#include <boost/serialization/singleton.hpp>
 #include <boost/serialization/extended_type_info.hpp>
-#include <boost/mpl/bool.hpp>
+#include <boost/serialization/factory.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
 #ifdef BOOST_MSVC
@@ -32,44 +34,37 @@
 
 namespace boost {
 namespace serialization {
-namespace detail {
 ///////////////////////////////////////////////////////////////////////
 // define a special type_info that doesn't depend on rtti which is not
 // available in all situations.
 
+namespace detail {
+
 // common base class to share type_info_key. This is used to
 // identify the method used to keep track of the extended type
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_no_rtti_0 :
     public extended_type_info
 {
- virtual bool
- less_than(const boost::serialization::extended_type_info &rhs) const ;
 protected:
     extended_type_info_no_rtti_0();
- // account for bogus gcc warning
- #if defined(__GNUC__)
- virtual
- #endif
     ~extended_type_info_no_rtti_0();
 public:
- struct is_polymorphic
- {
- typedef boost::mpl::bool_<true> type;
- BOOST_STATIC_CONSTANT(bool, value = is_polymorphic::type::value);
- };
+ virtual bool
+ is_less_than(const boost::serialization::extended_type_info &rhs) const ;
+ virtual bool
+ is_equal(const boost::serialization::extended_type_info &rhs) const ;
 };
 
+} // detail
+
 template<class T>
-class extended_type_info_no_rtti_1 :
- public extended_type_info_no_rtti_0
+class extended_type_info_no_rtti :
+ public detail::extended_type_info_no_rtti_0,
+ public singleton<extended_type_info_no_rtti<T> >
 {
-protected:
- extended_type_info_no_rtti_1(){}
 public:
- // note borland complains at making this destructor protected
- ~extended_type_info_no_rtti_1(){};
- static const boost::serialization::extended_type_info *
- get_derived_extended_type_info(const T & t){
+ const extended_type_info *
+ get_derived_extended_type_info(const T & t) const {
         // find the type that corresponds to the most derived type.
         // this implementation doesn't depend on typeid() but assumes
         // that the specified type has a function of the following signature.
@@ -79,30 +74,31 @@
         assert(NULL != derived_key);
         return boost::serialization::extended_type_info::find(derived_key);
     }
- static boost::serialization::extended_type_info *
- get_instance(){
- static extended_type_info_no_rtti_1<T> instance;
- return & instance;
+ void * construct(unsigned int count, ...) const{
+ // count up the arguments
+ std::va_list ap;
+ va_start(ap, count);
+ switch(count){
+ case 0:
+ return factory<T, 0>(ap);
+ case 1:
+ return factory<T, 1>(ap);
+ case 2:
+ return factory<T, 2>(ap);
+ case 3:
+ return factory<T, 3>(ap);
+ case 4:
+ return factory<T, 4>(ap);
+ default:
+ assert(false); // too many arguments
+ // throw exception here?
+ return NULL;
+ }
     }
- static void
- export_register(const char * key){
- boost::serialization::extended_type_info * eti;
- eti = get_instance();
- eti->key_register(key); // initialize key and add to table
- eti->self_register(); // add type to type table
+ void destroy(void const * const p) const{
+ delete static_cast<T const *>(p) ;
     }
 };
-} // namespace detail
-
-template<class T>
-class extended_type_info_no_rtti :
- public detail::extended_type_info_no_rtti_1<const T>
-{
- // private constructor to inhibit any existence other than the
- // static one
- extended_type_info_no_rtti(){}
- ~extended_type_info_no_rtti(){};
-};
 
 } // namespace serialization
 } // namespace boost
@@ -119,14 +115,14 @@
     template<class T>
     struct extended_type_info_impl {
         typedef BOOST_DEDUCED_TYPENAME
- boost::serialization::extended_type_info_no_rtti<const T> type;
+ boost::serialization::extended_type_info_no_rtti<T> type;
     };
     } // namespace serialization
     } // namespace boost
 #endif
 
 #ifdef BOOST_MSVC
-#pragma warning(pop)
+# pragma warning(pop)
 #endif
 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
 

Modified: trunk/boost/serialization/extended_type_info_typeid.hpp
==============================================================================
--- trunk/boost/serialization/extended_type_info_typeid.hpp (original)
+++ trunk/boost/serialization/extended_type_info_typeid.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -1,5 +1,6 @@
 #ifndef BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
 #define BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
+
 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
 // MS compatible compilers support #pragma once
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -18,15 +19,18 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 
 #include <typeinfo>
+#include <cstdarg>
+
 #include <boost/config.hpp>
 
-//#include <boost/static_warning.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/static_warning.hpp>
 #include <boost/type_traits/is_polymorphic.hpp>
-#include <boost/type_traits/is_const.hpp>
-#include <boost/preprocessor/stringize.hpp>
+#include <boost/type_traits/remove_const.hpp>
 
+#include <boost/serialization/singleton.hpp>
 #include <boost/serialization/extended_type_info.hpp>
+#include <boost/serialization/factory.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last header
 #ifdef BOOST_MSVC
@@ -36,80 +40,85 @@
 
 namespace boost {
 namespace serialization {
-
 namespace detail {
 
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_typeid_0 :
     public extended_type_info
 {
-private:
- virtual bool
- less_than(const extended_type_info &rhs) const;
 protected:
- static const extended_type_info *
- get_derived_extended_type_info(const std::type_info & ti);
+ const std::type_info * m_ti;
     extended_type_info_typeid_0();
- // account for bogus gcc warning
- #if defined(__GNUC__)
- virtual
- #endif
     ~extended_type_info_typeid_0();
+ void type_register(const std::type_info & ti);
+ void type_unregister();
+ const extended_type_info *
+ get_extended_type_info(const std::type_info & ti) const;
 public:
- virtual const std::type_info & get_eti() const = 0;
+ virtual bool
+ is_less_than(const extended_type_info &rhs) const;
+ virtual bool
+ is_equal(const extended_type_info &rhs) const;
+ const std::type_info & get_typeid() const {
+ return *m_ti;
+ }
 };
 
-///////////////////////////////////////////////////////////////////////////////
-// layer to fold T and const T into the same table entry.
+} // namespace detail
+
 template<class T>
-class extended_type_info_typeid_1 :
- public detail::extended_type_info_typeid_0
+class extended_type_info_typeid :
+ public detail::extended_type_info_typeid_0,
+ public singleton<extended_type_info_typeid<T> >
 {
-private:
- virtual const std::type_info & get_eti() const {
- return typeid(T);
- }
-protected:
- // private constructor to inhibit any existence other than the
- // static one
- extended_type_info_typeid_1() :
+public:
+ extended_type_info_typeid() :
         detail::extended_type_info_typeid_0()
     {
- self_register(); // add type to type table
+ type_register(typeid(T));
     }
-public:
- struct is_polymorphic
- {
- typedef BOOST_DEDUCED_TYPENAME boost::is_polymorphic<T>::type type;
- BOOST_STATIC_CONSTANT(bool, value = is_polymorphic::type::value);
- };
- static const extended_type_info *
- get_derived_extended_type_info(const T & t){
+ ~extended_type_info_typeid(){
+ type_unregister();
+ }
+ // get the eti record for the true type of this record
+ // relying upon standard type info implemenation (rtti)
+ const extended_type_info *
+ get_derived_extended_type_info(const T & t) const {
         // note: this implementation - based on usage of typeid (rtti)
- // only works if the class has at least one virtual function.
-// BOOST_STATIC_WARNING(
-// static_cast<bool>(is_polymorphic::value)
-// );
- return detail::extended_type_info_typeid_0::get_derived_extended_type_info(typeid(t));
- }
- static extended_type_info *
- get_instance(){
- static extended_type_info_typeid_1<T> instance;
- return & instance;
- }
- static void
- export_register(const char * key){
- get_instance()->key_register(key);
+ // only does something if the class has at least one virtual function.
+ BOOST_STATIC_WARNING(
+ static_cast<bool>(boost::is_polymorphic<T>::value)
+ );
+ return
+ detail::extended_type_info_typeid_0::get_extended_type_info(
+ typeid(t)
+ );
+ }
+ void * construct(unsigned int count, ...) const{
+ // count up the arguments
+ std::va_list ap;
+ va_start(ap, count);
+ switch(count){
+ case 0:
+ return factory<boost::remove_const<T>, 0>(ap);
+ case 1:
+ return factory<boost::remove_const<T>, 1>(ap);
+ case 2:
+ return factory<boost::remove_const<T>, 2>(ap);
+ case 3:
+ return factory<boost::remove_const<T>, 3>(ap);
+ case 4:
+ return factory<boost::remove_const<T>, 4>(ap);
+ default:
+ assert(false); // too many arguments
+ // throw exception here?
+ return NULL;
+ }
+ }
+ void destroy(void const * const p) const{
+ delete static_cast<T const *>(p) ;
     }
 };
 
-} // namespace detail
-
-///////////////////////////////////////////////////////////////////////////////
-template<class T>
-class extended_type_info_typeid :
- public detail::extended_type_info_typeid_1<const T>
-{};
-
 } // namespace serialization
 } // namespace boost
 

Added: trunk/boost/serialization/factory.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/serialization/factory.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -0,0 +1,92 @@
+#ifndef BOOST_SERIALIZATION_FACTORY_HPP
+#define BOOST_SERIALIZATION_FACTORY_HPP
+
+/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// factory.hpp: create an instance from an extended_type_info instance.
+
+// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
+// Use, modification and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <cstdarg>
+
+#include <boost/preprocessor/control/if.hpp>
+#include <boost/preprocessor/comparison/greater.hpp>
+#include <boost/preprocessor/facilities/empty.hpp>
+
+namespace std{
+ #if defined(__LIBCOMO__)
+ using ::va_list;
+ #endif
+} // namespace std
+
+namespace boost {
+namespace serialization {
+
+// default implementation does nothing.
+template<class T, int N>
+T * factory(std::va_list){
+ assert(false);
+ // throw exception here?
+ return NULL;
+}
+
+} // namespace serialization
+} // namespace boost
+
+#define BOOST_SERIALIZATION_FACTORY(N, T, A0, A1, A2, A3) \
+namespace boost { \
+namespace serialization { \
+ template<> \
+ T * factory<T, N>(std::va_list ap){ \
+ BOOST_PP_IF(BOOST_PP_GREATER(N,0) \
+ ,A0 a0 = va_arg(ap, A0); \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \
+ ,A1 a1 = va_arg(ap, A1); \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \
+ ,A2 a2 = va_arg(ap, A2); \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \
+ ,A3 a3 = va_arg(ap, A3); \
+ ,BOOST_PP_EMPTY() \
+ )))) \
+ return new T( \
+ BOOST_PP_IF(BOOST_PP_GREATER(N,0) \
+ ,a0 \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,1) \
+ ,a1 \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,2) \
+ ,a2 \
+ ,BOOST_PP_IF(BOOST_PP_GREATER(N,3) \
+ ,a3 \
+ ,BOOST_PP_EMPTY() \
+ )))) \
+ ); \
+ } \
+} \
+} \
+/**/
+
+#define BOOST_SERIALIZATION_FACTORY_4(T, A0, A1, A2, A3) \
+ BOOST_SERIALIZATION_FACTORY(4, T, A0, A1, A2, A3)
+
+#define BOOST_SERIALIZATION_FACTORY_3(T, A0, A1, A2) \
+ BOOST_SERIALIZATION_FACTORY(3, T, A0, A1, A2, 0)
+
+#define BOOST_SERIALIZATION_FACTORY_2(T, A0, A1) \
+ BOOST_SERIALIZATION_FACTORY(2, T, A0, A1, 0, 0)
+
+#define BOOST_SERIALIZATION_FACTORY_1(T, A0) \
+ BOOST_SERIALIZATION_FACTORY(1, T, A0, 0, 0, 0)
+
+#define BOOST_SERIALIZATION_FACTORY_0(T) \
+ BOOST_SERIALIZATION_FACTORY(0, T, 0, 0, 0, 0)
+
+#endif // BOOST_SERIALIZATION_FACTORY_HPP

Modified: trunk/boost/serialization/force_include.hpp
==============================================================================
--- trunk/boost/serialization/force_include.hpp (original)
+++ trunk/boost/serialization/force_include.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -16,10 +16,6 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
-// implementation of class export functionality. This is an alternative to
-// "forward declaration" method to provoke instantiation of derived classes
-// that are to be serialized through pointers.
-
 #include <boost/config.hpp>
 
 // the following help macro is to guarentee that certain coded

Modified: trunk/boost/serialization/is_abstract.hpp
==============================================================================
--- trunk/boost/serialization/is_abstract.hpp (original)
+++ trunk/boost/serialization/is_abstract.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -38,7 +38,7 @@
 namespace boost { \
 namespace serialization { \
 template<> \
-struct is_abstract< T > : mpl::true_ {}; \
+struct is_abstract<const T > : mpl::true_ {}; \
 }} \
 /**/
 

Modified: trunk/boost/serialization/optional.hpp
==============================================================================
--- trunk/boost/serialization/optional.hpp (original)
+++ trunk/boost/serialization/optional.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -20,6 +20,7 @@
 #include <boost/serialization/split_free.hpp>
 #include <boost/serialization/level.hpp>
 #include <boost/serialization/nvp.hpp>
+#include <boost/serialization/version.hpp>
 #include <boost/serialization/detail/stack_constructor.hpp>
 
 // function specializations must be defined in the appropriate
@@ -53,7 +54,7 @@
     bool tflag;
     ar >> boost::serialization::make_nvp("initialized", tflag);
     if (tflag){
- unsigned int v;
+ unsigned int v = 0;
         if(3 < ar.get_library_version()){
             ar >> make_nvp("item_version", v);
         }

Added: trunk/boost/serialization/singleton.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/serialization/singleton.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -0,0 +1,125 @@
+#ifndef BOOST_SERIALIZATION_SINGLETON_HPP
+#define BOOST_SERIALIZATION_SINGLETON_HPP
+
+/////////1/////////2///////// 3/////////4/////////5/////////6/////////7/////////8
+// singleton.hpp
+//
+// Copyright David Abrahams 2006. Original version
+//
+// Copyright Robert Ramey 2007. Changes made to permit
+// application throughout the serialization library.
+//
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// The intention here is to define a template which will convert
+// any class into a singleton with the following features:
+//
+// a) initialized before first use.
+// b) thread-safe for const access to the class
+// c) non-locking
+//
+// In order to do this,
+// a) Initialize dynamically when used.
+// b) Require that all singletons be initialized before main
+// is called or any entry point into the shared library is invoked.
+// This guarentees no race condition for initialization.
+// In debug mode, we assert that no non-const functions are called
+// after main is invoked.
+//
+
+// MS compatible compilers support #pragma once
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <cassert>
+#include <boost/noncopyable.hpp>
+#include <boost/serialization/force_include.hpp>
+
+namespace boost {
+namespace serialization {
+
+//////////////////////////////////////////////////////////////////////
+// Provides a dynamically-initialized (singleton) instance of T in a
+// way that avoids LNK1179 on vc6. See http://tinyurl.com/ljdp8 or
+// http://lists.boost.org/Archives/boost/2006/05/105286.php for
+// details.
+//
+
+// singletons created by this code are guarenteed to be unique
+// within the executable or shared library which creates them.
+// This is sufficient and in fact ideal for the serialization library.
+// The singleton is created when the module is loaded and destroyed
+// when the module is unloaded.
+
+// This base class has two functions.
+
+// First it provides a module handle for each singleton indicating
+// the executable or shared library in which it was created. This
+// turns out to be necessary and sufficient to implement the tables
+// used by serialization library.
+
+// Second, it provides a mechanism to detect when a non-const function
+// is called after initialization.
+
+// make a singleton to lock/unlock all singletons for alteration.
+// The intent is that all singletons created/used by this code
+// are to be initialized before main is called. A test program
+// can lock all the single
+
+class singleton_module : public boost::noncopyable
+{
+private:
+ static bool & get_lock(){
+ static bool lock = false;
+ return lock;
+ }
+public:
+// static const void * get_module_handle(){
+// return static_cast<const void *>(get_module_handle);
+// }
+ static void lock(){
+ get_lock() = true;
+ }
+ static void unlock(){
+ get_lock() = false;
+ }
+ static bool is_locked() {
+ return get_lock();
+ }
+};
+
+template <class T>
+class singleton : public singleton_module
+{
+private:
+ BOOST_DLLEXPORT static T & instance;
+ // include this to provoke instantiation at pre-execution time
+ static void use(T const &) {}
+ static T & get_instance(){
+ static T t;
+ // refer to instance, causing it to be instantiated (and
+ // initialized at startup on working compilers)
+ use(instance);
+ return t;
+ }
+public:
+ static T & get_mutable_instance(){
+ assert(! is_locked());
+ return get_instance();
+ }
+ static const T & get_const_instance(){
+ return get_instance();
+ }
+
+};
+
+template<class T>
+BOOST_DLLEXPORT T & singleton<T>::instance = singleton<T>::get_instance();
+
+} // namespace serialization
+} // namespace boost
+
+#endif // BOOST_SERIALIZATION_SINGLETON_HPP

Modified: trunk/boost/serialization/type_info_implementation.hpp
==============================================================================
--- trunk/boost/serialization/type_info_implementation.hpp (original)
+++ trunk/boost/serialization/type_info_implementation.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -61,7 +61,7 @@
 namespace serialization { \
 template<> \
 struct type_info_implementation< T > { \
- typedef ETI type; \
+ typedef const ETI type; \
 }; \
 } \
 } \

Modified: trunk/boost/serialization/void_cast.hpp
==============================================================================
--- trunk/boost/serialization/void_cast.hpp (original)
+++ trunk/boost/serialization/void_cast.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -18,13 +18,10 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 
 #include <boost/smart_cast.hpp>
-#include <boost/mpl/eval_if.hpp>
-#include <boost/mpl/identity.hpp>
-
-#include <boost/serialization/config.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/config/abi_prefix.hpp> // must be the last header
 
 #ifdef BOOST_MSVC
@@ -35,7 +32,7 @@
 namespace boost {
 namespace serialization {
 
-class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info;
+class extended_type_info;
 
 // Given a void *, assume that it really points to an instance of one type
 // and alter it so that it would point to an instance of a related type.
@@ -44,156 +41,121 @@
 
 BOOST_SERIALIZATION_DECL(void const *)
 void_upcast(
- extended_type_info const & derived_type,
- extended_type_info const & base_type,
- void const * const t,
- bool top = true
+ extended_type_info const & derived,
+ extended_type_info const & base,
+ void const * const t
 );
 
 inline void *
 void_upcast(
- extended_type_info const & derived_type_,
- extended_type_info const & base_type_,
+ extended_type_info const & derived,
+ extended_type_info const & base,
     void * const t
 ){
     return const_cast<void*>(void_upcast(
- derived_type_,
- base_type_,
+ derived,
+ base,
         const_cast<void const *>(t)
     ));
 }
 
 BOOST_SERIALIZATION_DECL(void const *)
 void_downcast(
- extended_type_info const & derived_type,
- extended_type_info const & base_type,
- void const * const t,
- bool top = true
+ extended_type_info const & derived,
+ extended_type_info const & base,
+ void const * const t
 );
 
 inline void *
 void_downcast(
- extended_type_info const & derived_type_,
- extended_type_info const & base_type_,
+ extended_type_info const & derived,
+ extended_type_info const & base,
     void * const t
 ){
     return const_cast<void*>(void_downcast(
- derived_type_,
- base_type_,
+ derived,
+ base,
         const_cast<void const *>(t)
     ));
 }
 
 namespace void_cast_detail {
 
-// note: can't be abstract because an instance is used as a search argument
 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) void_caster
 {
     friend struct void_caster_compare ;
     friend
- BOOST_SERIALIZATION_DECL(void const *)
+ BOOST_SERIALIZATION_DECL(void const *)
     boost::serialization::void_upcast(
- const extended_type_info & derived_type,
- const extended_type_info & base_type,
- const void * t,
- bool top
+ extended_type_info const & derived,
+ extended_type_info const & base,
+ void const * const
     );
     friend
     BOOST_SERIALIZATION_DECL(void const *)
     boost::serialization::void_downcast(
- const extended_type_info & derived_type,
- const extended_type_info & base_type,
- const void * t,
- bool top
+ extended_type_info const & derived,
+ extended_type_info const & base,
+ void const * const
     );
- // each derived class must re-implement these;
- virtual void const * upcast(void const * t) const = 0;
- virtual void const * downcast(void const * t) const = 0;
     // Data members
- extended_type_info const & m_derived_type;
- extended_type_info const & m_base_type;
+ 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:
- static void static_register(const void_caster *);
+ void
+ static_register() const;
+ void
+ static_unregister() const;
 public:
     // Constructor
     void_caster(
- extended_type_info const & derived_type_,
- extended_type_info const & base_type_
+ extended_type_info const & derived,
+ extended_type_info const & base
     );
- // predicate used to determine if this void caster includes
- // a particular eti *
- bool includes(const extended_type_info * eti) const;
- virtual ~void_caster();
-private:
- // cw 8.3 requires this!!
- void_caster& operator=(void_caster const&);
+ virtual ~void_caster(){};
+ bool operator==(const void_caster & rhs) const;
 };
 
 template <class Derived, class Base>
 class void_caster_primitive :
     public void_caster
 {
- virtual void const* downcast( void const * t ) const {
- Derived * d = boost::smart_cast<const Derived *, const Base *>(
+ virtual void const * downcast(void const * const t) const {
+ const Derived * d = boost::smart_cast<const Derived *, const Base *>(
             static_cast<const Base *>(t)
         );
         return d;
     }
- virtual void const* upcast(void const * t) const {
- Base * b = boost::smart_cast<const Base *, const Derived *>(
+ virtual void const * upcast(void const * const t) const {
+ const Base * b = boost::smart_cast<const Base *, const Derived *>(
             static_cast<const Derived *>(t)
         );
         return b;
     }
-
- BOOST_DLLEXPORT void_caster_primitive() BOOST_USED;
-
- static BOOST_DLLEXPORT void_caster_primitive const& instance;
-
- // Something we can use to force instantiation without generating
- // warnings.
- static void use(void_caster_primitive const&) {}
-
- public:
- // CodeWarrior fails to construct static members of class
- // templates when they are instantiated from within templates, so
- // we do everything with void_caster_primitive in terms of
- // get_instance. On CodeWarrior, the user must invoke
- // BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED to make this work
- // (see boost/serialization/export.hpp). On other compilers (and
- // if the bug is fixed in a future version of CodeWarriror), the
- // initialization of instance (above) obviates the need for
- // BOOST_SERIALIZATION_MWERKS_BASE_AND_DERIVED.
- static BOOST_DLLEXPORT void_caster_primitive const& get_instance()
- {
- static void_caster_primitive instance_;
-
- // refer to instance, causing it to be instantiated (and
- // initialized at startup on working compilers)
- use(instance);
-
- return instance_;
- }
+public:
+ 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_instance(),
- * type_info_implementation<Base>::type::get_instance()
+ type_info_implementation<Derived>::type::get_const_instance(),
+ type_info_implementation<Base>::type::get_const_instance()
     )
 {
- // calling get_instance() causes infinite recursion, and the
- // instance reference isn't initialized yet, so we must pass this
- // to static_register. It *is* the same object as instance, but
- // there's no way even to assert that here.
- this->static_register(this);
+ static_register();
 }
 
 template <class Derived, class Base>
-BOOST_DLLEXPORT void_caster_primitive<Derived,Base> const&
-void_caster_primitive<Derived,Base>::instance
-= void_caster_primitive<Derived,Base>::get_instance();
+void_caster_primitive<Derived, Base>::~void_caster_primitive(){
+ static_unregister();
+}
 
 } // void_cast_detail
 
@@ -207,20 +169,25 @@
     const Derived * dnull,
     const Base * bnull
 ) BOOST_USED;
+
 template<class Derived, class Base>
 BOOST_DLLEXPORT
 inline const void_cast_detail::void_caster & void_cast_register(
- const Derived * /* dnull = NULL */,
- const Base * /* bnull = NULL */
+ Derived const * /* dnull = NULL */,
+ Base const * /* bnull = NULL */
 ){
- return void_cast_detail::void_caster_primitive<
- const Derived, const Base
- >::get_instance();
+ return singleton<void_cast_detail::void_caster_primitive<
+ Derived, Base
+ > >::get_const_instance();
 }
 
 } // namespace serialization
 } // namespace boost
 
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
 
 #endif // BOOST_SERIALIZATION_VOID_CAST_HPP

Modified: trunk/boost/serialization/void_cast_fwd.hpp
==============================================================================
--- trunk/boost/serialization/void_cast_fwd.hpp (original)
+++ trunk/boost/serialization/void_cast_fwd.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -17,6 +17,8 @@
 
 // See http://www.boost.org for updates, documentation, and revision history.
 
+#include <boost/serialization/force_include.hpp>
+
 namespace boost {
 namespace serialization {
 namespace void_cast_detail{

Modified: trunk/boost/serialization/weak_ptr.hpp
==============================================================================
--- trunk/boost/serialization/weak_ptr.hpp (original)
+++ trunk/boost/serialization/weak_ptr.hpp 2008-03-18 00:58:51 EDT (Tue, 18 Mar 2008)
@@ -29,7 +29,7 @@
     const unsigned int /* file_version */
 ){
     const boost::shared_ptr<T> sp = t.lock();
- ar << boost::serialization::make_nvp(NULL, sp);
+ ar << boost::serialization::make_nvp("shared_ptr", sp);
 }
 
 template<class Archive, class T>
@@ -39,7 +39,7 @@
     const unsigned int /* file_version */
 ){
     boost::shared_ptr<T> sp;
- ar >> boost::serialization::make_nvp(NULL, sp);
+ ar >> boost::serialization::make_nvp("shared_ptr", sp);
     t = sp;
 }
 


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