summaryrefslogtreecommitdiff
path: root/boost/serialization/weak_ptr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/serialization/weak_ptr.hpp')
-rw-r--r--boost/serialization/weak_ptr.hpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/boost/serialization/weak_ptr.hpp b/boost/serialization/weak_ptr.hpp
index 3fe8698de3..6952d24cb3 100644
--- a/boost/serialization/weak_ptr.hpp
+++ b/boost/serialization/weak_ptr.hpp
@@ -2,12 +2,12 @@
#define BOOST_SERIALIZATION_WEAK_PTR_HPP
// MS compatible compilers support #pragma once
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#if defined(_MSC_VER)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
-// shared_ptr.hpp: serialization for boost shared pointer
+// weak_ptr.hpp: serialization for boost weak pointer
// (C) Copyright 2004 Robert Ramey and Martin Ecker
// Use, modification and distribution is subject to the Boost Software
@@ -55,4 +55,45 @@ inline void serialize(
} // namespace serialization
} // namespace boost
+#ifndef BOOST_NO_CXX11_SMART_PTR
+#include <memory>
+
+namespace boost {
+namespace serialization{
+
+template<class Archive, class T>
+inline void save(
+ Archive & ar,
+ const std::weak_ptr< T > &t,
+ const unsigned int /* file_version */
+){
+ const std::shared_ptr< T > sp = t.lock();
+ ar << boost::serialization::make_nvp("weak_ptr", sp);
+}
+
+template<class Archive, class T>
+inline void load(
+ Archive & ar,
+ std::weak_ptr< T > &t,
+ const unsigned int /* file_version */
+){
+ std::shared_ptr< T > sp;
+ ar >> boost::serialization::make_nvp("weak_ptr", sp);
+ t = sp;
+}
+
+template<class Archive, class T>
+inline void serialize(
+ Archive & ar,
+ std::weak_ptr< T > &t,
+ const unsigned int file_version
+){
+ boost::serialization::split_free(ar, t, file_version);
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif // BOOST_NO_CXX11_SMART_PTR
+
#endif // BOOST_SERIALIZATION_WEAK_PTR_HPP