shared_ptr -> std::shared_ptr

This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today.
This commit is contained in:
void_17
2026-03-02 15:58:20 +07:00
parent d63f79325f
commit 7074f35e4b
1373 changed files with 12054 additions and 12054 deletions

View File

@@ -2,7 +2,7 @@
#define BOOST_SHARED_PTR_132_HPP_INCLUDED
//
// shared_ptr.hpp
// std::shared_ptr.hpp
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002, 2003 Peter Dimov
@@ -11,7 +11,7 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
// See http://www.boost.org/libs/smart_ptr/std::shared_ptr.htm for documentation.
//
#include <boost/config.hpp> // for broken compiler workarounds
@@ -96,18 +96,18 @@ inline void sp_enable_shared_from_this( shared_count const & /*pn*/, ... )
//
// shared_ptr
// std::shared_ptr
//
// An enhanced relative of scoped_ptr with reference counted copy semantics.
// The object pointed to is deleted when the last shared_ptr pointing to it
// The object pointed to is deleted when the last std::shared_ptr pointing to it
// is destroyed or reset.
//
template<class T> class shared_ptr
template<class T> class std::shared_ptr
{
private:
// Borland 5.5.1 specific workaround
typedef shared_ptr< T > this_type;
typedef std::shared_ptr< T > this_type;
public:
@@ -116,16 +116,16 @@ public:
typedef T * pointer;
typedef BOOST_DEDUCED_TYPENAME detail::shared_ptr_traits< T >::reference reference;
shared_ptr(): px(0), pn() // never throws in 1.30+
std::shared_ptr(): px(0), pn() // never throws in 1.30+
{
}
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x564) )
template<class Y>
explicit shared_ptr(Y * p): px(p), pn(p, boost::checked_deleter<Y>()) // Y must be complete
explicit std::shared_ptr(Y * p): px(p), pn(p, boost::checked_deleter<Y>()) // Y must be complete
#else
template<class Y>
explicit shared_ptr(Y * p): px(p), pn(p, boost::checked_deleter<Y>()) // Y must be complete
explicit std::shared_ptr(Y * p): px(p), pn(p, boost::checked_deleter<Y>()) // Y must be complete
#endif
{
detail::sp_enable_shared_from_this( pn, p, p );
@@ -134,10 +134,10 @@ public:
//
// Requirements: D's copy constructor must not throw
//
// shared_ptr will release p by calling d(p)
// std::shared_ptr will release p by calling d(p)
//
template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d)
template<class Y, class D> std::shared_ptr(Y * p, D d): px(p), pn(p, d)
{
detail::sp_enable_shared_from_this( pn, p, p );
}
@@ -147,7 +147,7 @@ public:
// except that Borland C++ has a bug, and g++ with -Wsynth warns
#if defined(__BORLANDC__) || defined(__GNUC__)
shared_ptr & operator=(shared_ptr const & r) // never throws
std::shared_ptr & operator=(std::shared_ptr const & r) // never throws
{
px = r.px;
pn = r.pn; // shared_count::op= doesn't throw
@@ -157,29 +157,29 @@ public:
#endif
template<class Y>
explicit shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw
explicit std::shared_ptr(weak_ptr<Y> const & r): pn(r.pn) // may throw
{
// it is now safe to copy r.px, as pn(r.pn) did not throw
px = r.px;
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
std::shared_ptr(std::shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn)
std::shared_ptr(std::shared_ptr<Y> const & r, detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn)
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn)
std::shared_ptr(std::shared_ptr<Y> const & r, detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn)
{
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
std::shared_ptr(std::shared_ptr<Y> const & r, detail::dynamic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
{
if(px == 0) // need to allocate new counter -- the cast failed
{
@@ -188,7 +188,7 @@ public:
}
template<class Y>
shared_ptr(shared_ptr<Y> const & r, detail::polymorphic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
std::shared_ptr(std::shared_ptr<Y> const & r, detail::polymorphic_cast_tag): px(dynamic_cast<element_type *>(r.px)), pn(r.pn)
{
if(px == 0)
{
@@ -199,7 +199,7 @@ public:
#ifndef BOOST_NO_AUTO_PTR
template<class Y>
explicit shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn()
explicit std::shared_ptr(std::auto_ptr<Y> & r): px(r.get()), pn()
{
Y * tmp = r.get();
pn = detail::shared_count(r);
@@ -211,7 +211,7 @@ public:
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
template<class Y>
shared_ptr & operator=(shared_ptr<Y> const & r) // never throws
std::shared_ptr & operator=(std::shared_ptr<Y> const & r) // never throws
{
px = r.px;
pn = r.pn; // shared_count::op= doesn't throw
@@ -223,7 +223,7 @@ public:
#ifndef BOOST_NO_AUTO_PTR
template<class Y>
shared_ptr & operator=(std::auto_ptr<Y> & r)
std::shared_ptr & operator=(std::auto_ptr<Y> & r)
{
this_type(r).swap(*this);
return *this;
@@ -258,7 +258,7 @@ public:
BOOST_ASSERT(px != 0);
return px;
}
T * get() const // never throws
{
return px;
@@ -275,13 +275,13 @@ public:
#elif defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
typedef T * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const // never throws
{
return px == 0? 0: &this_type::get;
}
#else
#else
typedef T * this_type::*unspecified_bool_type;
@@ -309,13 +309,13 @@ public:
return pn.use_count();
}
void swap(shared_ptr< T > & other) // never throws
void swap(std::shared_ptr< T > & other) // never throws
{
std::swap(px, other.px);
pn.swap(other.pn);
}
template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const
template<class Y> bool _internal_less(std::shared_ptr<Y> const & rhs) const
{
return pn < rhs.pn;
}
@@ -332,7 +332,7 @@ public:
private:
template<class Y> friend class shared_ptr;
template<class Y> friend class std::shared_ptr;
template<class Y> friend class weak_ptr;
@@ -341,14 +341,14 @@ public: // for serialization
T * px; // contained pointer
detail::shared_count pn; // reference counter
}; // shared_ptr
}; // std::shared_ptr
template<class T, class U> inline bool operator==(shared_ptr< T > const & a, shared_ptr<U> const & b)
template<class T, class U> inline bool operator==(std::shared_ptr< T > const & a, std::shared_ptr<U> const & b)
{
return a.get() == b.get();
}
template<class T, class U> inline bool operator!=(shared_ptr< T > const & a, shared_ptr<U> const & b)
template<class T, class U> inline bool operator!=(std::shared_ptr< T > const & a, std::shared_ptr<U> const & b)
{
return a.get() != b.get();
}
@@ -357,64 +357,64 @@ template<class T, class U> inline bool operator!=(shared_ptr< T > const & a, sha
// Resolve the ambiguity between our op!= and the one in rel_ops
template<class T> inline bool operator!=(shared_ptr< T > const & a, shared_ptr< T > const & b)
template<class T> inline bool operator!=(std::shared_ptr< T > const & a, std::shared_ptr< T > const & b)
{
return a.get() != b.get();
}
#endif
template<class T, class U> inline bool operator<(shared_ptr< T > const & a, shared_ptr<U> const & b)
template<class T, class U> inline bool operator<(std::shared_ptr< T > const & a, std::shared_ptr<U> const & b)
{
return a._internal_less(b);
}
template<class T> inline void swap(shared_ptr< T > & a, shared_ptr< T > & b)
template<class T> inline void swap(std::shared_ptr< T > & a, std::shared_ptr< T > & b)
{
a.swap(b);
}
template<class T, class U> shared_ptr< T > static_pointer_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > static_pointer_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::static_cast_tag());
return std::shared_ptr< T >(r, detail::static_cast_tag());
}
template<class T, class U> shared_ptr< T > const_pointer_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > const_pointer_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::const_cast_tag());
return std::shared_ptr< T >(r, detail::const_cast_tag());
}
template<class T, class U> shared_ptr< T > dynamic_pointer_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > dynamic_pointer_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::dynamic_cast_tag());
return std::shared_ptr< T >(r, detail::dynamic_cast_tag());
}
// shared_*_cast names are deprecated. Use *_pointer_cast instead.
template<class T, class U> shared_ptr< T > shared_static_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > shared_static_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::static_cast_tag());
return std::shared_ptr< T >(r, detail::static_cast_tag());
}
template<class T, class U> shared_ptr< T > shared_dynamic_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > shared_dynamic_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::dynamic_cast_tag());
return std::shared_ptr< T >(r, detail::dynamic_cast_tag());
}
template<class T, class U> shared_ptr< T > shared_polymorphic_cast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > shared_polymorphic_cast(std::shared_ptr<U> const & r)
{
return shared_ptr< T >(r, detail::polymorphic_cast_tag());
return std::shared_ptr< T >(r, detail::polymorphic_cast_tag());
}
template<class T, class U> shared_ptr< T > shared_polymorphic_downcast(shared_ptr<U> const & r)
template<class T, class U> std::shared_ptr< T > shared_polymorphic_downcast(std::shared_ptr<U> const & r)
{
BOOST_ASSERT(dynamic_cast<T *>(r.get()) == r.get());
return shared_static_cast< T >(r);
}
// get_pointer() enables boost::mem_fn to recognize shared_ptr
// get_pointer() enables boost::mem_fn to recognize std::shared_ptr
template<class T> inline T * get_pointer(shared_ptr< T > const & p)
template<class T> inline T * get_pointer(std::shared_ptr< T > const & p)
{
return p.get();
}
@@ -423,7 +423,7 @@ template<class T> inline T * get_pointer(shared_ptr< T > const & p)
#if defined(__GNUC__) && (__GNUC__ < 3)
template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p)
template<class Y> std::ostream & operator<< (std::ostream & os, std::shared_ptr<Y> const & p)
{
os << p.get();
return os;
@@ -434,10 +434,10 @@ template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> co
# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT)
// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL
using std::basic_ostream;
template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p)
template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, std::shared_ptr<Y> const & p)
# else
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
# endif
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, std::shared_ptr<Y> const & p)
# endif
{
os << p.get();
return os;
@@ -452,7 +452,7 @@ template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::
// g++ 2.9x doesn't allow static_cast<X const *>(void *)
// apparently EDG 2.38 also doesn't accept it
template<class D, class T> D * get_deleter(shared_ptr< T > const & p)
template<class D, class T> D * get_deleter(std::shared_ptr< T > const & p)
{
void const * q = p._internal_get_deleter(typeid(D));
return const_cast<D *>(static_cast<D const *>(q));
@@ -460,7 +460,7 @@ template<class D, class T> D * get_deleter(shared_ptr< T > const & p)
#else
template<class D, class T> D * get_deleter(shared_ptr< T > const & p)
template<class D, class T> D * get_deleter(std::shared_ptr< T > const & p)
{
return static_cast<D *>(p._internal_get_deleter(typeid(D)));
}
@@ -471,7 +471,7 @@ template<class D, class T> D * get_deleter(shared_ptr< T > const & p)
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
#endif
#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)

View File

@@ -2,7 +2,7 @@
#define BOOST_DETAIL_SHARED_PTR_NMT_132_HPP_INCLUDED
//
// detail/shared_ptr_nmt.hpp - shared_ptr.hpp without member templates
// detail/shared_ptr_nmt.hpp - std::shared_ptr.hpp without member templates
//
// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002 Peter Dimov
@@ -11,7 +11,7 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation.
// See http://www.boost.org/libs/smart_ptr/std::shared_ptr.htm for documentation.
//
#include <boost/assert.hpp>
@@ -30,7 +30,7 @@
namespace boost
{
template<class T> class shared_ptr
template<class T> class std::shared_ptr
{
private:
@@ -41,7 +41,7 @@ public:
typedef T element_type;
typedef T value_type;
explicit shared_ptr(T * p = 0): px(p)
explicit std::shared_ptr(T * p = 0): px(p)
{
#ifndef BOOST_NO_EXCEPTIONS
@@ -68,7 +68,7 @@ public:
#endif
}
~shared_ptr()
~std::shared_ptr()
{
if(--*pn == 0)
{
@@ -77,29 +77,29 @@ public:
}
}
shared_ptr(shared_ptr const & r): px(r.px) // never throws
std::shared_ptr(std::shared_ptr const & r): px(r.px) // never throws
{
pn = r.pn;
++*pn;
}
shared_ptr & operator=(shared_ptr const & r)
std::shared_ptr & operator=(std::shared_ptr const & r)
{
shared_ptr(r).swap(*this);
std::shared_ptr(r).swap(*this);
return *this;
}
#ifndef BOOST_NO_AUTO_PTR
explicit shared_ptr(std::auto_ptr< T > & r)
{
explicit std::shared_ptr(std::auto_ptr< T > & r)
{
pn = new count_type(1); // may throw
px = r.release(); // fix: moved here to stop leak if new throws
}
}
shared_ptr & operator=(std::auto_ptr< T > & r)
std::shared_ptr & operator=(std::auto_ptr< T > & r)
{
shared_ptr(r).swap(*this);
std::shared_ptr(r).swap(*this);
return *this;
}
@@ -108,7 +108,7 @@ public:
void reset(T * p = 0)
{
BOOST_ASSERT(p == 0 || p != px);
shared_ptr(p).swap(*this);
std::shared_ptr(p).swap(*this);
}
T & operator*() const // never throws
@@ -137,8 +137,8 @@ public:
{
return *pn == 1;
}
void swap(shared_ptr< T > & other) // never throws
void swap(std::shared_ptr< T > & other) // never throws
{
std::swap(px, other.px);
std::swap(pn, other.pn);
@@ -150,29 +150,29 @@ private:
count_type * pn; // ptr to reference counter
};
template<class T, class U> inline bool operator==(shared_ptr< T > const & a, shared_ptr<U> const & b)
template<class T, class U> inline bool operator==(std::shared_ptr< T > const & a, std::shared_ptr<U> const & b)
{
return a.get() == b.get();
}
template<class T, class U> inline bool operator!=(shared_ptr< T > const & a, shared_ptr<U> const & b)
template<class T, class U> inline bool operator!=(std::shared_ptr< T > const & a, std::shared_ptr<U> const & b)
{
return a.get() != b.get();
}
template<class T> inline bool operator<(shared_ptr< T > const & a, shared_ptr< T > const & b)
template<class T> inline bool operator<(std::shared_ptr< T > const & a, std::shared_ptr< T > const & b)
{
return std::less<T*>()(a.get(), b.get());
}
template<class T> void swap(shared_ptr< T > & a, shared_ptr< T > & b)
template<class T> void swap(std::shared_ptr< T > & a, std::shared_ptr< T > & b)
{
a.swap(b);
}
// get_pointer() enables boost::mem_fn to recognize shared_ptr
// get_pointer() enables boost::mem_fn to recognize std::shared_ptr
template<class T> inline T * get_pointer(shared_ptr< T > const & p)
template<class T> inline T * get_pointer(std::shared_ptr< T > const & p)
{
return p.get();
}

View File

@@ -7,7 +7,7 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr.hpp: serialization for boost shared pointer
// std::shared_ptr.hpp: serialization for boost shared pointer
// (C) Copyright 2004 Robert Ramey and Martin Ecker
// Use, modification and distribution is subject to the Boost Software
@@ -23,7 +23,7 @@
#include <boost/mpl/integral_c_tag.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/nvp.hpp>
@@ -31,7 +31,7 @@
#include <boost/serialization/tracking.hpp>
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr serialization traits
// std::shared_ptr serialization traits
// version 1 to distinguish from boost 1.32 version. Note: we can only do this
// for a template when the compiler supports partial template specialization
@@ -39,7 +39,7 @@
namespace boost {
namespace serialization{
template<class T>
struct version< ::boost::shared_ptr< T > > {
struct version< ::boost::std::shared_ptr< T > > {
typedef mpl::integral_c_tag tag;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
typedef BOOST_DEDUCED_TYPENAME mpl::int_<1> type;
@@ -54,7 +54,7 @@
};
// don't track shared pointers
template<class T>
struct tracking_level< ::boost::shared_ptr< T > > {
struct tracking_level< ::boost::std::shared_ptr< T > > {
typedef mpl::integral_c_tag tag;
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206))
typedef BOOST_DEDUCED_TYPENAME mpl::int_< ::boost::serialization::track_never> type;
@@ -73,11 +73,11 @@
// define macro to let users of these compilers do this
#define BOOST_SERIALIZATION_SHARED_PTR(T) \
BOOST_CLASS_VERSION( \
::boost::shared_ptr< T >, \
::boost::std::shared_ptr< T >, \
1 \
) \
BOOST_CLASS_TRACKING( \
::boost::shared_ptr< T >, \
::boost::std::shared_ptr< T >, \
::boost::serialization::track_never \
) \
/**/
@@ -91,16 +91,16 @@ struct null_deleter {
};
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// serialization for shared_ptr
// serialization for std::shared_ptr
template<class Archive, class T>
inline void save(
Archive & ar,
const boost::shared_ptr< T > &t,
const boost::std::shared_ptr< T > &t,
const unsigned int /* file_version */
){
// The most common cause of trapping here would be serializing
// something like shared_ptr<int>. This occurs because int
// something like std::shared_ptr<int>. This occurs because int
// is never tracked by default. Wrap int in a trackable type
BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
const T * t_ptr = t.get();
@@ -111,11 +111,11 @@ inline void save(
template<class Archive, class T>
inline void load(
Archive & ar,
boost::shared_ptr< T > &t,
boost::std::shared_ptr< T > &t,
const unsigned int file_version
){
// The most common cause of trapping here would be serializing
// something like shared_ptr<int>. This occurs because int
// something like std::shared_ptr<int>. This occurs because int
// is never tracked by default. Wrap int in a trackable type
BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
T* r;
@@ -126,7 +126,7 @@ inline void load(
ar.register_type(static_cast<
boost_132::detail::sp_counted_base_impl<T *, null_deleter > *
>(NULL));
boost_132::shared_ptr< T > sp;
boost_132::std::shared_ptr< T > sp;
ar >> boost::serialization::make_nvp("px", sp.px);
ar >> boost::serialization::make_nvp("pn", sp.pn);
// got to keep the sps around so the sp.pns don't disappear
@@ -143,11 +143,11 @@ inline void load(
template<class Archive, class T>
inline void load(
Archive & ar,
boost::shared_ptr< T > &t,
boost::std::shared_ptr< T > &t,
const unsigned int /*file_version*/
){
// The most common cause of trapping here would be serializing
// something like shared_ptr<int>. This occurs because int
// something like std::shared_ptr<int>. This occurs because int
// is never tracked by default. Wrap int in a trackable type
BOOST_STATIC_ASSERT((tracking_level< T >::value != track_never));
T* r;
@@ -159,10 +159,10 @@ inline void load(
template<class Archive, class T>
inline void serialize(
Archive & ar,
boost::shared_ptr< T > &t,
boost::std::shared_ptr< T > &t,
const unsigned int file_version
){
// correct shared_ptr serialization depends upon object tracking
// correct std::shared_ptr serialization depends upon object tracking
// being used.
BOOST_STATIC_ASSERT(
boost::serialization::tracking_level< T >::value

View File

@@ -7,9 +7,9 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr.hpp: serialization for boost shared pointer
// std::shared_ptr.hpp: serialization for boost shared pointer
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// (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)
@@ -17,8 +17,8 @@
// See http://www.boost.org for updates, documentation, and revision history.
// note: totally unadvised hack to gain access to private variables
// in shared_ptr and shared_count. Unfortunately its the only way to
// do this without changing shared_ptr and shared_count
// in std::shared_ptr and shared_count. Unfortunately its the only way to
// do this without changing std::shared_ptr and shared_count
// the best we can do is to detect a conflict here
#include <boost/config.hpp>
@@ -38,7 +38,7 @@
// Maintain a couple of lists of loaded shared pointers of the old previous
// version (1.32)
namespace boost_132 {
namespace boost_132 {
namespace serialization {
namespace detail {
@@ -53,7 +53,7 @@ struct null_deleter {
/////////////////////////////////////////////////////////////
// sp_counted_base_impl serialization
namespace boost {
namespace boost {
namespace serialization {
template<class Archive, class P, class D>
@@ -66,7 +66,7 @@ inline void serialize(
// its polymorphic base
boost::serialization::void_cast_register<
boost_132::detail::sp_counted_base_impl<P, D>,
boost_132::detail::sp_counted_base
boost_132::detail::sp_counted_base
>(
static_cast<boost_132::detail::sp_counted_base_impl<P, D> *>(NULL),
static_cast<boost_132::detail::sp_counted_base *>(NULL)
@@ -76,8 +76,8 @@ inline void serialize(
template<class Archive, class P, class D>
inline void save_construct_data(
Archive & ar,
const
boost_132::detail::sp_counted_base_impl<P, D> *t,
const
boost_132::detail::sp_counted_base_impl<P, D> *t,
const BOOST_PFTO unsigned int /* file_version */
){
// variables used for construction
@@ -87,25 +87,25 @@ inline void save_construct_data(
template<class Archive, class P, class D>
inline void load_construct_data(
Archive & ar,
boost_132::detail::sp_counted_base_impl<P, D> * t,
boost_132::detail::sp_counted_base_impl<P, D> * t,
const unsigned int /* file_version */
){
P ptr_;
ar >> boost::serialization::make_nvp("ptr", ptr_);
// ::new(t)boost_132::detail::sp_counted_base_impl<P, D>(ptr_, D());
// ::new(t)boost_132::detail::sp_counted_base_impl<P, D>(ptr_, D());
// placement
// note: the original ::new... above is replaced by the one here. This one
// creates all new objects with a null_deleter so that after the archive
// is finished loading and the shared_ptrs are destroyed - the underlying
// raw pointers are NOT deleted. This is necessary as they are used by the
// raw pointers are NOT deleted. This is necessary as they are used by the
// new system as well.
::new(t)boost_132::detail::sp_counted_base_impl<
P,
P,
boost_132::serialization::detail::null_deleter
>(
ptr_, boost_132::serialization::detail::null_deleter()
); // placement new
// compensate for that fact that a new shared count always is
// compensate for that fact that a new shared count always is
// initialized with one. the add_ref_copy below will increment it
// every time its serialized so without this adjustment
// the use and weak counts will be off by one.
@@ -118,7 +118,7 @@ inline void load_construct_data(
/////////////////////////////////////////////////////////////
// shared_count serialization
namespace boost {
namespace boost {
namespace serialization {
template<class Archive>
@@ -147,15 +147,15 @@ inline void load(
BOOST_SERIALIZATION_SPLIT_FREE(boost_132::detail::shared_count)
/////////////////////////////////////////////////////////////
// implement serialization for shared_ptr< T >
// implement serialization for std::shared_ptr< T >
namespace boost {
namespace boost {
namespace serialization {
template<class Archive, class T>
inline void save(
Archive & ar,
const boost_132::shared_ptr< T > &t,
const boost_132::std::shared_ptr< T > &t,
const unsigned int /* file_version */
){
// only the raw pointer has to be saved
@@ -170,7 +170,7 @@ inline void save(
template<class Archive, class T>
inline void load(
Archive & ar,
boost_132::shared_ptr< T > &t,
boost_132::std::shared_ptr< T > &t,
const unsigned int /* file_version */
){
// only the raw pointer has to be saved
@@ -185,10 +185,10 @@ inline void load(
template<class Archive, class T>
inline void serialize(
Archive & ar,
boost_132::shared_ptr< T > &t,
boost_132::std::shared_ptr< T > &t,
const unsigned int file_version
){
// correct shared_ptr serialization depends upon object tracking
// correct std::shared_ptr serialization depends upon object tracking
// being used.
BOOST_STATIC_ASSERT(
boost::serialization::tracking_level< T >::value
@@ -200,7 +200,7 @@ inline void serialize(
} // serialization
} // namespace boost
// note: change below uses null_deleter
// note: change below uses null_deleter
// This macro is used to export GUIDS for shared pointers to allow
// the serialization system to export them properly. David Tonge
#define BOOST_SHARED_POINTER_EXPORT_GUID(T, K) \

View File

@@ -7,7 +7,7 @@
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// shared_ptr.hpp: serialization for boost shared pointer
// std::shared_ptr.hpp: serialization for boost shared pointer
// (C) Copyright 2004 Robert Ramey and Martin Ecker
// Use, modification and distribution is subject to the Boost Software
@@ -17,7 +17,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
#include <boost/weak_ptr.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/std::shared_ptr.hpp>
namespace boost {
namespace serialization{
@@ -28,7 +28,7 @@ inline void save(
const boost::weak_ptr< T > &t,
const unsigned int /* file_version */
){
const boost::shared_ptr< T > sp = t.lock();
const boost::std::shared_ptr< T > sp = t.lock();
ar << boost::serialization::make_nvp("weak_ptr", sp);
}
@@ -38,7 +38,7 @@ inline void load(
boost::weak_ptr< T > &t,
const unsigned int /* file_version */
){
boost::shared_ptr< T > sp;
boost::std::shared_ptr< T > sp;
ar >> boost::serialization::make_nvp("weak_ptr", sp);
t = sp;
}