updated boost on windows
This commit is contained in:
@@ -23,6 +23,8 @@ namespace std{
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/array_wrapper.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -55,7 +55,7 @@ struct binary_object :
|
||||
m_size = rhs.m_size;
|
||||
return *this;
|
||||
}
|
||||
binary_object(/* const */ void * const t, std::size_t size) :
|
||||
binary_object(const void * const t, std::size_t size) :
|
||||
m_t(t),
|
||||
m_size(size)
|
||||
{}
|
||||
@@ -69,7 +69,7 @@ struct binary_object :
|
||||
// wrappers follow the naming convention make_xxxxx
|
||||
inline
|
||||
const binary_object
|
||||
make_binary_object(/* const */ void * t, std::size_t size){
|
||||
make_binary_object(const void * t, std::size_t size){
|
||||
return binary_object(t, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#define BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#ifndef BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
#define BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
@@ -30,4 +30,4 @@ void serialize(Archive& ar, boost::array<T,N>& a, const unsigned int /* version
|
||||
} } // end namespace boost::serialization
|
||||
|
||||
|
||||
#endif //BOOST_SERIALIZATION_ARRAY_HPP
|
||||
#endif //BOOST_SERIALIZATION_BOOST_ARRAY_HPP
|
||||
|
||||
@@ -64,7 +64,7 @@ collection_load_impl(
|
||||
Archive & ar,
|
||||
T & t,
|
||||
collection_size_type count,
|
||||
item_version_type
|
||||
item_version_type /*item_version*/
|
||||
){
|
||||
t.resize(count);
|
||||
typename T::iterator hint;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// helper function templates for serialization of collections
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/version.hpp>
|
||||
@@ -60,7 +61,7 @@ inline void save_collection(
|
||||
// note borland emits a no-op without the explicit namespace
|
||||
boost::serialization::save_construct_data_adl(
|
||||
ar,
|
||||
&(*it),
|
||||
boost::addressof(*it),
|
||||
item_version
|
||||
);
|
||||
ar << boost::serialization::make_nvp("item", *it++);
|
||||
|
||||
@@ -18,31 +18,37 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 1101) \
|
||||
|| ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
namespace boost{
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_default_constructible : std::is_default_constructible<T> {};
|
||||
struct is_default_constructible : public std::is_default_constructible<T> {};
|
||||
|
||||
} // detail
|
||||
} // serializaition
|
||||
} // boost
|
||||
#else
|
||||
// we don't have standard library support for is_default_constructible
|
||||
// so we fake it by using boost::has_trivial_construtor. But this is not
|
||||
// actually correct because it's possible that a default constructor
|
||||
// to be non trivial. So when using this, make sure you're not using your
|
||||
// own definition of of T() but are using the actual default one!
|
||||
#include <boost/type_traits/has_trivial_constructor.hpp>
|
||||
namespace boost{
|
||||
namespace serialization {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct is_default_constructible : boost::has_trivial_constructor<T> {};
|
||||
struct is_default_constructible : public boost::has_trivial_constructor<T> {};
|
||||
|
||||
} // detail
|
||||
} // serializaition
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BOOST_SERIALIZATION_DETAIL_IS_DEFAULT_CONSTRUCTIBLE_HPP
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
@@ -48,32 +48,33 @@ 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() \
|
||||
)))) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \
|
||||
, A0 a0 = va_arg(ap, A0);, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \
|
||||
, A1 a1 = va_arg(ap, A1);, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \
|
||||
, A2 a2 = va_arg(ap, A2);, BOOST_PP_EMPTY()) \
|
||||
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() \
|
||||
)))) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 0) \
|
||||
, a0, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 1) \
|
||||
, a1, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 2) \
|
||||
, a2, BOOST_PP_EMPTY()) \
|
||||
BOOST_PP_IF(BOOST_PP_GREATER(N, 3)) \
|
||||
, BOOST_PP_COMMA, BOOST_PP_EMPTY)() \
|
||||
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)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <boost/serialization/traits.hpp>
|
||||
#include <boost/serialization/wrapper.hpp>
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
@@ -43,7 +45,7 @@ struct nvp :
|
||||
public:
|
||||
explicit nvp(const char * name_, T & t) :
|
||||
// note: added _ to suppress useless gcc warning
|
||||
std::pair<const char *, T *>(name_, & t)
|
||||
std::pair<const char *, T *>(name_, boost::addressof(t))
|
||||
{}
|
||||
|
||||
const char * name() const {
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/serialization/detail/stack_constructor.hpp>
|
||||
#include <boost/serialization/detail/is_default_constructible.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
|
||||
// function specializations must be defined in the appropriate
|
||||
// namespace - boost::serialization
|
||||
@@ -46,24 +47,15 @@ void save(
|
||||
// default constructor. It's possible that this could change sometime
|
||||
// in the future, but for now, one will have to work around it. This can
|
||||
// be done by serialization the optional<T> as optional<T *>
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
);
|
||||
#if ! defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::serialization::detail::is_default_constructible<T>::value
|
||||
|| boost::is_pointer<T>::value
|
||||
);
|
||||
#endif
|
||||
const bool tflag = t.is_initialized();
|
||||
ar << boost::serialization::make_nvp("initialized", tflag);
|
||||
if (tflag){
|
||||
const boost::serialization::item_version_type item_version(version< T >::value);
|
||||
#if 0
|
||||
const boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
};
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar << BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
#else
|
||||
ar << BOOST_SERIALIZATION_NVP(item_version);
|
||||
#endif
|
||||
ar << boost::serialization::make_nvp("value", *t);
|
||||
}
|
||||
}
|
||||
@@ -72,7 +64,7 @@ template<class Archive, class T>
|
||||
void load(
|
||||
Archive & ar,
|
||||
boost::optional< T > & t,
|
||||
const unsigned int /*version*/
|
||||
const unsigned int version
|
||||
){
|
||||
bool tflag;
|
||||
ar >> boost::serialization::make_nvp("initialized", tflag);
|
||||
@@ -81,20 +73,18 @@ void load(
|
||||
return;
|
||||
}
|
||||
|
||||
boost::serialization::item_version_type item_version(0);
|
||||
boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
);
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar >> BOOST_SERIALIZATION_NVP(item_version);
|
||||
if(0 == version){
|
||||
boost::serialization::item_version_type item_version(0);
|
||||
boost::archive::library_version_type library_version(
|
||||
ar.get_library_version()
|
||||
);
|
||||
if(boost::archive::library_version_type(3) < library_version){
|
||||
ar >> BOOST_SERIALIZATION_NVP(item_version);
|
||||
}
|
||||
}
|
||||
detail::stack_allocate<T> tp;
|
||||
ar >> boost::serialization::make_nvp("value", tp.reference());
|
||||
t.reset(boost::move(tp.reference()));
|
||||
ar.reset_object_address(
|
||||
t.get_ptr(),
|
||||
& tp.reference()
|
||||
);
|
||||
if(! t.is_initialized())
|
||||
t = T();
|
||||
ar >> boost::serialization::make_nvp("value", *t);
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
@@ -106,7 +96,12 @@ void serialize(
|
||||
boost::serialization::split_free(ar, t, version);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
struct version<boost::optional<T> > {
|
||||
BOOST_STATIC_CONSTANT(int, value = 1);
|
||||
};
|
||||
|
||||
} // serialization
|
||||
} // namespace boost
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_SERIALIZATION_OPTIONAL_HPP_
|
||||
|
||||
@@ -57,7 +57,8 @@ inline void load_set_collection(Archive & ar, Container &s)
|
||||
ar >> boost::serialization::make_nvp("item", t.reference());
|
||||
typename Container::iterator result =
|
||||
s.insert(hint, boost::move(t.reference()));
|
||||
ar.reset_object_address(& (* result), & t.reference());
|
||||
const type * new_address = & (* result);
|
||||
ar.reset_object_address(new_address, & t.reference());
|
||||
hint = result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// Copyright Robert Ramey 2007. Changes made to permit
|
||||
// application throughout the serialization library.
|
||||
//
|
||||
// Copyright Alexander Grund 2018. Corrections to singleton lifetime
|
||||
//
|
||||
// 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)
|
||||
@@ -32,15 +34,15 @@
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/serialization/config.hpp>
|
||||
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/serialization/config.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
@@ -48,8 +50,8 @@
|
||||
# pragma warning(disable : 4511 4512)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Provides a dynamically-initialized (singleton) instance of T in a
|
||||
@@ -58,7 +60,7 @@ namespace serialization {
|
||||
// details.
|
||||
//
|
||||
|
||||
// singletons created by this code are guarenteed to be unique
|
||||
// Singletons created by this code are guaranteed 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
|
||||
@@ -74,91 +76,141 @@ namespace serialization {
|
||||
// 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.
|
||||
// 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 singletons when main is entereed. This any
|
||||
// attempt to retieve a mutable instances while locked will
|
||||
// generate a assertion if compiled for debug.
|
||||
// can lock all the singletons when main is entered. Thus any
|
||||
// attempt to retrieve a mutable instance while locked will
|
||||
// generate an assertion if compiled for debug.
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE singleton_module :
|
||||
public boost::noncopyable
|
||||
{
|
||||
private:
|
||||
BOOST_SERIALIZATION_DECL static bool & get_lock();
|
||||
public:
|
||||
static void lock(){
|
||||
get_lock() = true;
|
||||
}
|
||||
// The singleton template can be used in 2 ways:
|
||||
// 1 (Recommended): Publicly inherit your type T from singleton<T>,
|
||||
// make its ctor protected and access it via T::get_const_instance()
|
||||
// 2: Simply access singleton<T> without changing T. Note that this only
|
||||
// provides a global instance accesible by singleton<T>::get_const_instance()
|
||||
// or singleton<T>::get_mutable_instance() to prevent using multiple instances
|
||||
// of T make its ctor protected
|
||||
|
||||
static void unlock(){
|
||||
get_lock() = false;
|
||||
}
|
||||
|
||||
static bool is_locked(){
|
||||
return get_lock();
|
||||
}
|
||||
};
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
class singleton_wrapper : public T
|
||||
{
|
||||
public:
|
||||
static bool m_is_destroyed;
|
||||
~singleton_wrapper(){
|
||||
m_is_destroyed = true;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
bool detail::singleton_wrapper< T >::m_is_destroyed = false;
|
||||
|
||||
} // detail
|
||||
|
||||
// note usage of BOOST_DLLEXPORT. These functions are in danger of
|
||||
// Note on usage of BOOST_DLLEXPORT: These functions are in danger of
|
||||
// being eliminated by the optimizer when building an application in
|
||||
// release mode. Usage of the macro is meant to signal the compiler/linker
|
||||
// to avoid dropping these functions which seem to be unreferenced.
|
||||
// This usage is not related to autolinking.
|
||||
|
||||
template <class T>
|
||||
class singleton : public singleton_module
|
||||
class BOOST_SYMBOL_VISIBLE singleton_module :
|
||||
public boost::noncopyable
|
||||
{
|
||||
private:
|
||||
BOOST_DLLEXPORT static T & instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const *) {}
|
||||
BOOST_DLLEXPORT static T & get_instance() {
|
||||
static detail::singleton_wrapper< T > t;
|
||||
// refer to instance, causing it to be instantiated (and
|
||||
// initialized at startup on working compilers)
|
||||
BOOST_ASSERT(! detail::singleton_wrapper< T >::m_is_destroyed);
|
||||
use(& instance);
|
||||
return static_cast<T &>(t);
|
||||
BOOST_DLLEXPORT bool & get_lock() BOOST_USED {
|
||||
static bool lock = false;
|
||||
return lock;
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT void lock(){
|
||||
get_lock() = true;
|
||||
}
|
||||
BOOST_DLLEXPORT void unlock(){
|
||||
get_lock() = false;
|
||||
}
|
||||
BOOST_DLLEXPORT bool is_locked(){
|
||||
return get_lock();
|
||||
}
|
||||
};
|
||||
|
||||
static inline singleton_module & get_singleton_module(){
|
||||
static singleton_module m;
|
||||
return m;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
// This is the class actually instantiated and hence the real singleton.
|
||||
// So there will only be one instance of this class. This does not hold
|
||||
// for singleton<T> as a class derived from singleton<T> could be
|
||||
// instantiated multiple times.
|
||||
// It also provides a flag `is_destroyed` which returns true, when the
|
||||
// class was destructed. It is static and hence accesible even after
|
||||
// destruction. This can be used to check, if the singleton is still
|
||||
// accesible e.g. in destructors of other singletons.
|
||||
template<class T>
|
||||
class singleton_wrapper : public T
|
||||
{
|
||||
static bool & get_is_destroyed(){
|
||||
// Prefer a static function member to avoid LNK1179.
|
||||
// Note: As this is for a singleton (1 instance only) it must be set
|
||||
// never be reset (to false)!
|
||||
static bool is_destroyed_flag = false;
|
||||
return is_destroyed_flag;
|
||||
}
|
||||
public:
|
||||
singleton_wrapper(){
|
||||
BOOST_ASSERT(! is_destroyed());
|
||||
}
|
||||
~singleton_wrapper(){
|
||||
get_is_destroyed() = true;
|
||||
}
|
||||
static bool is_destroyed(){
|
||||
return get_is_destroyed();
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
template <class T>
|
||||
class singleton {
|
||||
private:
|
||||
static T * m_instance;
|
||||
// include this to provoke instantiation at pre-execution time
|
||||
static void use(T const &) {}
|
||||
static T & get_instance() {
|
||||
BOOST_ASSERT(! is_destroyed());
|
||||
|
||||
// use a wrapper so that types T with protected constructors can be used
|
||||
// Using a static function member avoids LNK1179
|
||||
static detail::singleton_wrapper< T > t;
|
||||
|
||||
// note that the following is absolutely essential.
|
||||
// commenting out this statement will cause compilers to fail to
|
||||
// construct the instance at pre-execution time. This would prevent
|
||||
// our usage/implementation of "locking" and introduce uncertainty into
|
||||
// the sequence of object initialization.
|
||||
// Unfortunately, this triggers detectors of undefine behavior
|
||||
// and reports an error. But I've been unable to find a different
|
||||
// of guarenteeing that the the singleton is created at pre-main time.
|
||||
use(* m_instance);
|
||||
|
||||
return static_cast<T &>(t);
|
||||
}
|
||||
protected:
|
||||
// Do not allow instantiation of a singleton<T>. But we want to allow
|
||||
// `class T: public singleton<T>` so we can't delete this ctor
|
||||
BOOST_DLLEXPORT singleton(){}
|
||||
|
||||
public:
|
||||
BOOST_DLLEXPORT static T & get_mutable_instance(){
|
||||
BOOST_ASSERT(! is_locked());
|
||||
BOOST_ASSERT(! get_singleton_module().is_locked());
|
||||
return get_instance();
|
||||
}
|
||||
BOOST_DLLEXPORT static const T & get_const_instance(){
|
||||
return get_instance();
|
||||
}
|
||||
BOOST_DLLEXPORT static bool is_destroyed(){
|
||||
return detail::singleton_wrapper< T >::m_is_destroyed;
|
||||
return detail::singleton_wrapper< T >::is_destroyed();
|
||||
}
|
||||
};
|
||||
|
||||
// Assigning the instance reference to a static member forces initialization
|
||||
// at startup time as described in
|
||||
// https://groups.google.com/forum/#!topic/microsoft.public.vc.language/kDVNLnIsfZk
|
||||
template<class T>
|
||||
BOOST_DLLEXPORT T & singleton< T >::instance = singleton< T >::get_instance();
|
||||
T * singleton< T >::m_instance = & singleton< T >::get_instance();
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <valarray>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
#include <boost/serialization/collections_save_imp.hpp>
|
||||
#include <boost/serialization/collections_load_imp.hpp>
|
||||
@@ -47,7 +48,7 @@ void save( Archive & ar, const STD::valarray<U> &t, const unsigned int /*file_ve
|
||||
if (t.size()){
|
||||
// explict template arguments to pass intel C++ compiler
|
||||
ar << serialization::make_array<const U, collection_size_type>(
|
||||
static_cast<const U *>(&t[0]),
|
||||
static_cast<const U *>( boost::addressof(t[0]) ),
|
||||
count
|
||||
);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ void load( Archive & ar, STD::valarray<U> &t, const unsigned int /*file_version
|
||||
if (t.size()){
|
||||
// explict template arguments to pass intel C++ compiler
|
||||
ar >> serialization::make_array<U, collection_size_type>(
|
||||
static_cast<U *>(&t[0]),
|
||||
static_cast<U *>( boost::addressof(t[0]) ),
|
||||
count
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<class Archive>
|
||||
struct variant_save_visitor :
|
||||
boost::static_visitor<>
|
||||
struct variant_save_visitor :
|
||||
boost::static_visitor<>
|
||||
{
|
||||
variant_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
@@ -100,7 +100,8 @@ struct variant_impl {
|
||||
head_type value;
|
||||
ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
v = value;
|
||||
ar.reset_object_address(& boost::get<head_type>(v), & value);
|
||||
head_type * new_address = & boost::get<head_type>(v);
|
||||
ar.reset_object_address(new_address, & value);
|
||||
return;
|
||||
}
|
||||
typedef typename mpl::pop_front<S>::type type;
|
||||
@@ -155,4 +156,23 @@ inline void serialize(
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
//template<typename T0_, BOOST_VARIANT_ENUM_SHIFTED_PARAMS(typename T)>
|
||||
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template<BOOST_VARIANT_ENUM_PARAMS(/* typename */ class T)>
|
||||
struct tracking_level<
|
||||
variant<BOOST_VARIANT_ENUM_PARAMS(T)>
|
||||
>{
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_< ::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
};
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif //BOOST_SERIALIZATION_VARIANT_HPP
|
||||
|
||||
@@ -181,13 +181,14 @@ 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(),
|
||||
// note:I wanted to displace from 0 here, but at least one compiler
|
||||
// treated 0 by not shifting it at all.
|
||||
/* note about displacement:
|
||||
* displace 0: at least one compiler treated 0 by not shifting it at all
|
||||
* displace by small value (8): caused ICE on certain mingw gcc versions */
|
||||
reinterpret_cast<std::ptrdiff_t>(
|
||||
static_cast<Derived *>(
|
||||
reinterpret_cast<Base *>(8)
|
||||
reinterpret_cast<Base *>(1 << 20)
|
||||
)
|
||||
) - 8
|
||||
) - (1 << 20)
|
||||
)
|
||||
{
|
||||
recursive_register();
|
||||
|
||||
Reference in New Issue
Block a user