summaryrefslogtreecommitdiff
path: root/boost/serialization
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
commit3fdc3e5ee96dca5b11d1694975a65200787eab86 (patch)
tree5c1733853892b8397d67706fa453a9bd978d2102 /boost/serialization
parent88e602c57797660ebe0f9e15dbd64c1ff16dead3 (diff)
downloadboost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.gz
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.bz2
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.zip
Imported Upstream version 1.66.0upstream/1.66.0
Diffstat (limited to 'boost/serialization')
-rw-r--r--boost/serialization/collections_save_imp.hpp3
-rw-r--r--boost/serialization/nvp.hpp4
-rw-r--r--boost/serialization/singleton.hpp24
-rw-r--r--boost/serialization/valarray.hpp5
4 files changed, 29 insertions, 7 deletions
diff --git a/boost/serialization/collections_save_imp.hpp b/boost/serialization/collections_save_imp.hpp
index f3cabfcf3f..5ada155e24 100644
--- a/boost/serialization/collections_save_imp.hpp
+++ b/boost/serialization/collections_save_imp.hpp
@@ -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++);
diff --git a/boost/serialization/nvp.hpp b/boost/serialization/nvp.hpp
index 4e2297b3cc..066fe94d87 100644
--- a/boost/serialization/nvp.hpp
+++ b/boost/serialization/nvp.hpp
@@ -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 {
diff --git a/boost/serialization/singleton.hpp b/boost/serialization/singleton.hpp
index b50afedbb9..0bde1f9551 100644
--- a/boost/serialization/singleton.hpp
+++ b/boost/serialization/singleton.hpp
@@ -91,7 +91,11 @@ class BOOST_SYMBOL_VISIBLE singleton_module :
public boost::noncopyable
{
private:
- BOOST_SERIALIZATION_DECL BOOST_DLLEXPORT static bool & get_lock() BOOST_USED;
+ BOOST_DLLEXPORT static bool & get_lock() BOOST_USED {
+ static bool lock = false;
+ return lock;
+ }
+
public:
BOOST_DLLEXPORT static void lock(){
get_lock() = true;
@@ -115,17 +119,28 @@ private:
// use a wrapper so that types T with protected constructors
// can be used
class singleton_wrapper : public T {};
- static singleton_wrapper t;
+
+ // Use a heap-allocated instance to work around static variable
+ // destruction order issues: this inner singleton_wrapper<>
+ // instance may be destructed before the singleton<> instance.
+ // Using a 'dumb' static variable lets us precisely choose the
+ // time destructor is invoked.
+ static singleton_wrapper *t = 0;
+
// refer to instance, causing it to be instantiated (and
// initialized at startup on working compilers)
BOOST_ASSERT(! is_destroyed());
+
// 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 initializaition.
use(& m_instance);
- return static_cast<T &>(t);
+
+ if (!t)
+ t = new singleton_wrapper;
+ return static_cast<T &>(*t);
}
static bool & get_is_destroyed(){
static bool is_destroyed;
@@ -147,6 +162,9 @@ public:
get_is_destroyed() = false;
}
BOOST_DLLEXPORT ~singleton() {
+ if (!get_is_destroyed()) {
+ delete &(get_instance());
+ }
get_is_destroyed() = true;
}
};
diff --git a/boost/serialization/valarray.hpp b/boost/serialization/valarray.hpp
index 9eece5c173..e7ec81a569 100644
--- a/boost/serialization/valarray.hpp
+++ b/boost/serialization/valarray.hpp
@@ -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
);
}