1
--- shared_ptr.hpp.KEEP 2011-02-09 11:54:05.203963701 -0500
2
+++ shared_ptr.hpp 2011-02-10 08:27:24.643133773 -0500
4
# pragma warning(disable:4284) // odd return type for operator->
7
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
8
+void boost_debug_shared_ptr_operator_equals (void const *, void const *, int, void const*, int);
9
+void boost_debug_shared_ptr_reset (void const *, void const *, int, void const*, int);
10
+void boost_debug_shared_ptr_destructor (void const *, void const *, int);
11
+void boost_debug_shared_ptr_constructor (void const *, void const *, int);
19
shared_ptr(): px(0), pn() // never throws in 1.30+
21
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
22
+ boost_debug_shared_ptr_constructor (this, px, use_count());
28
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
29
+ boost_debug_shared_ptr_destructor (this, get(), use_count());
33
+ shared_ptr(const shared_ptr<T>& r ) : px (r.px), pn (r.pn) {
34
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
35
+ boost_debug_shared_ptr_constructor (this, px, use_count());
40
explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete
42
boost::detail::sp_enable_shared_from_this( this, p, p );
43
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
44
+ boost_debug_shared_ptr_constructor (this, px, use_count());
51
template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d)
53
- boost::detail::sp_enable_shared_from_this( this, p, p );
54
+ boost::detail::sp_enable_shared_from_this( this, p, p );
55
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
56
+ boost_debug_shared_ptr_constructor (this, px, 9249 /*use_count()*/);
60
// As above, but with allocator. A's copy constructor shall not throw.
62
template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
64
boost::detail::sp_enable_shared_from_this( this, p, p );
65
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
66
+ boost_debug_shared_ptr_constructor (this, px, use_count());
70
// generated copy constructor, destructor are fine
73
// it is now safe to copy r.px, as pn(r.pn) did not throw
75
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
76
+ boost_debug_shared_ptr_constructor (this, px, use_count());
85
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
86
+ boost_debug_shared_ptr_constructor (this, px, use_count());
93
: px( r.px ), pn( r.pn ) // never throws
95
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
96
+ boost_debug_shared_ptr_constructor (this, px, use_count());
102
shared_ptr( shared_ptr<Y> const & r, T * p ): px( p ), pn( r.pn ) // never throws
104
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
105
+ boost_debug_shared_ptr_constructor (this, px, use_count());
110
shared_ptr(shared_ptr<Y> const & r, boost::detail::static_cast_tag): px(static_cast<element_type *>(r.px)), pn(r.pn)
112
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
113
+ boost_debug_shared_ptr_constructor (this, px, use_count());
118
shared_ptr(shared_ptr<Y> const & r, boost::detail::const_cast_tag): px(const_cast<element_type *>(r.px)), pn(r.pn)
120
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
121
+ boost_debug_shared_ptr_constructor (this, px, use_count());
128
pn = boost::detail::shared_count();
130
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
131
+ boost_debug_shared_ptr_constructor (this, px, use_count());
138
boost::throw_exception(std::bad_cast());
140
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
141
+ boost_debug_shared_ptr_constructor (this, px, use_count());
145
#ifndef BOOST_NO_AUTO_PTR
148
pn = boost::detail::shared_count(r);
149
boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
150
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
151
+ boost_debug_shared_ptr_constructor (this, px, use_count());
155
#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
157
typename Ap::element_type * tmp = r.get();
158
pn = boost::detail::shared_count( r );
159
boost::detail::sp_enable_shared_from_this( this, tmp, tmp );
160
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
161
+ boost_debug_shared_ptr_constructor (this, px, use_count());
168
shared_ptr & operator=( shared_ptr const & r ) // never throws
170
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
171
+ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count());
173
this_type(r).swap(*this);
178
shared_ptr & operator=(shared_ptr<Y> const & r) // never throws
180
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
181
+ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count());
183
this_type(r).swap(*this);
188
shared_ptr & operator=( std::auto_ptr<Y> & r )
190
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
191
+ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count());
193
this_type(r).swap(*this);
200
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
201
+ boost_debug_shared_ptr_constructor (this, px, use_count());
206
@@ -364,10 +438,16 @@
210
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
211
+ boost_debug_shared_ptr_constructor (this, px, use_count());
215
shared_ptr & operator=( shared_ptr && r ) // never throws
217
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
218
+ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count());
220
this_type( static_cast< shared_ptr && >( r ) ).swap( *this );
225
shared_ptr & operator=( shared_ptr<Y> && r ) // never throws
227
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
228
+ boost_debug_shared_ptr_operator_equals (this, get(), use_count(), r.get(), r.use_count());
230
this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
233
@@ -383,27 +466,42 @@
235
void reset() // never throws in 1.30+
237
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
238
+ boost_debug_shared_ptr_reset (this, get(), use_count(), 0, 0);
240
this_type().swap(*this);
243
template<class Y> void reset(Y * p) // Y must be complete
245
BOOST_ASSERT(p == 0 || p != px); // catch self-reset errors
246
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
247
+ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0);
249
this_type(p).swap(*this);
252
template<class Y, class D> void reset( Y * p, D d )
254
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
255
+ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0);
257
this_type( p, d ).swap( *this );
260
template<class Y, class D, class A> void reset( Y * p, D d, A a )
262
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
263
+ boost_debug_shared_ptr_reset (this, get(), use_count(), p, 0);
265
this_type( p, d, a ).swap( *this );
268
template<class Y> void reset( shared_ptr<Y> const & r, T * p )
270
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
271
+ boost_debug_shared_ptr_reset (this, get(), use_count(), r.get(), r.use_count());
273
this_type( r, p ).swap( *this );