00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #ifndef _BOOST_SHARED_PTR_H
00055 #define _BOOST_SHARED_PTR_H 1
00056
00057
00058 namespace std
00059 {
00060 namespace tr1
00061 {
00062
00063 class bad_weak_ptr : public std::exception
00064 {
00065 public:
00066
00067 virtual char const* what() const throw()
00068 {
00069 return "tr1::bad_weak_ptr";
00070 }
00071 };
00072
00073
00074
00075 inline void
00076 __throw_bad_weak_ptr()
00077 {
00078 #if __EXCEPTIONS
00079 throw bad_weak_ptr();
00080 #else
00081 std::abort();
00082 #endif
00083 }
00084
00085
00086 template <typename _Tp>
00087 struct _Sp_deleter
00088 {
00089 typedef void result_type;
00090 typedef _Tp* argument_type;
00091
00092 void
00093 operator()(_Tp* p) const
00094 { delete p; }
00095 };
00096
00097
00098 class _Sp_counted_base
00099 {
00100 public:
00101
00102 _Sp_counted_base()
00103 : _M_use_count(1), _M_weak_count(1)
00104 { }
00105
00106 virtual
00107 ~_Sp_counted_base()
00108 { }
00109
00110
00111
00112 virtual void
00113 dispose() = 0;
00114
00115
00116 virtual void
00117 destroy()
00118 {
00119 delete this;
00120 }
00121
00122 virtual void*
00123 get_deleter(const std::type_info&) = 0;
00124
00125 void
00126 add_ref_copy()
00127 {
00128 __gnu_cxx::__atomic_add(&_M_use_count, 1);
00129 }
00130
00131 void
00132 add_ref_lock()
00133 {
00134 __gnu_cxx::lock lock(_M_mutex);
00135 if (__gnu_cxx::__exchange_and_add(&_M_use_count, 1) == 0)
00136 {
00137 _M_use_count = 0;
00138 __throw_bad_weak_ptr();
00139 }
00140 }
00141
00142 void
00143 release()
00144 {
00145 if (__gnu_cxx::__exchange_and_add(&_M_use_count, -1) == 1)
00146 {
00147 dispose();
00148 __glibcxx_mutex_lock(_M_mutex);
00149 __glibcxx_mutex_unlock(_M_mutex);
00150 weak_release();
00151 }
00152 }
00153
00154 void
00155 weak_add_ref()
00156 {
00157 __gnu_cxx::__atomic_add(&_M_weak_count, 1);
00158 }
00159
00160 void
00161 weak_release()
00162 {
00163 if (__gnu_cxx::__exchange_and_add(&_M_weak_count, -1) == 1)
00164 {
00165 __glibcxx_mutex_lock(_M_mutex);
00166 __glibcxx_mutex_unlock(_M_mutex);
00167 destroy();
00168 }
00169 }
00170
00171 long
00172 use_count() const
00173 {
00174 return _M_use_count;
00175 }
00176
00177 private:
00178
00179 _Sp_counted_base(_Sp_counted_base const&);
00180 _Sp_counted_base& operator= (_Sp_counted_base const&);
00181
00182 _Atomic_word _M_use_count;
00183 _Atomic_word _M_weak_count;
00184 __gnu_cxx::mutex_type _M_mutex;
00185 };
00186
00187 template <typename _Ptr, typename _Deleter>
00188 class _Sp_counted_base_impl : public _Sp_counted_base
00189 {
00190 public:
00191
00192
00193
00194
00195
00196 _Sp_counted_base_impl(_Ptr __p, _Deleter __d)
00197 : _M_ptr(__p), _M_del(__d)
00198 { }
00199
00200 virtual void
00201 dispose()
00202 {
00203 _M_del(_M_ptr);
00204 }
00205
00206 virtual void*
00207 get_deleter(const std::type_info& __ti)
00208 {
00209 return __ti == typeid(_Deleter) ? &_M_del : 0;
00210 }
00211
00212 private:
00213 _Sp_counted_base_impl(const _Sp_counted_base_impl&);
00214 _Sp_counted_base_impl& operator=(const _Sp_counted_base_impl&);
00215
00216 _Ptr _M_ptr;
00217 _Deleter _M_del;
00218 };
00219
00220 class weak_count;
00221
00222 class shared_count
00223 {
00224 private:
00225
00226 _Sp_counted_base* _M_pi;
00227
00228 friend class weak_count;
00229
00230 public:
00231
00232 shared_count()
00233 : _M_pi(0)
00234 { }
00235
00236 template <typename _Ptr, typename _Deleter>
00237 shared_count(_Ptr __p, _Deleter __d)
00238 : _M_pi(0)
00239 {
00240 try
00241 {
00242 _M_pi = new _Sp_counted_base_impl<_Ptr, _Deleter>(__p, __d);
00243 }
00244 catch(...)
00245 {
00246 __d(__p);
00247 __throw_exception_again;
00248 }
00249 }
00250
00251
00252
00253 template <typename _Tp>
00254 explicit shared_count(std::auto_ptr<_Tp>& __r)
00255 : _M_pi(new _Sp_counted_base_impl<_Tp*,_Sp_deleter<_Tp> >(
00256 __r.get(), _Sp_deleter<_Tp>()
00257 ))
00258 { __r.release(); }
00259
00260
00261 explicit shared_count(const weak_count& __r);
00262
00263 ~shared_count()
00264 {
00265 if (_M_pi != 0)
00266 _M_pi->release();
00267 }
00268
00269 shared_count(const shared_count& __r)
00270 : _M_pi(__r._M_pi)
00271 {
00272 if (_M_pi != 0)
00273 _M_pi->add_ref_copy();
00274 }
00275
00276 shared_count&
00277 operator=(const shared_count& __r)
00278 {
00279 _Sp_counted_base* __tmp = __r._M_pi;
00280
00281 if(__tmp != _M_pi)
00282 {
00283 if(__tmp != 0)
00284 __tmp->add_ref_copy();
00285 if(_M_pi != 0)
00286 _M_pi->release();
00287 _M_pi = __tmp;
00288 }
00289 return *this;
00290 }
00291
00292 void swap(shared_count& __r)
00293 {
00294 _Sp_counted_base* __tmp = __r._M_pi;
00295 __r._M_pi = _M_pi;
00296 _M_pi = __tmp;
00297 }
00298
00299 long
00300 use_count() const
00301 { return _M_pi != 0 ? _M_pi->use_count() : 0; }
00302
00303 bool
00304 unique() const
00305 { return this->use_count() == 1; }
00306
00307 friend inline bool
00308 operator==(const shared_count& __a, const shared_count& __b)
00309 { return __a._M_pi == __b._M_pi; }
00310
00311 friend inline bool
00312 operator<(const shared_count& __a, const shared_count& __b)
00313 { return std::less<_Sp_counted_base*>()(__a._M_pi, __b._M_pi); }
00314
00315 void*
00316 get_deleter(const std::type_info& __ti) const
00317 { return _M_pi ? _M_pi->get_deleter(__ti) : 0; }
00318 };
00319
00320
00321 class weak_count
00322 {
00323 private:
00324
00325 _Sp_counted_base * _M_pi;
00326
00327 friend class shared_count;
00328
00329 public:
00330
00331 weak_count()
00332 : _M_pi(0)
00333 { }
00334
00335 weak_count(const shared_count& __r)
00336 : _M_pi(__r._M_pi)
00337 {
00338 if (_M_pi != 0)
00339 _M_pi->weak_add_ref();
00340 }
00341
00342 weak_count(const weak_count& __r)
00343 : _M_pi(__r._M_pi)
00344 {
00345 if (_M_pi != 0)
00346 _M_pi->weak_add_ref();
00347 }
00348
00349 ~weak_count()
00350 {
00351 if (_M_pi != 0)
00352 _M_pi->weak_release();
00353 }
00354
00355 weak_count&
00356 operator=(const shared_count& __r)
00357 {
00358 _Sp_counted_base* __tmp = __r._M_pi;
00359 if (__tmp != 0)
00360 __tmp->weak_add_ref();
00361 if (_M_pi != 0)
00362 _M_pi->weak_release();
00363 _M_pi = __tmp;
00364
00365 return *this;
00366 }
00367
00368 weak_count&
00369 operator=(const weak_count& __r)
00370 {
00371 _Sp_counted_base * __tmp = __r._M_pi;
00372 if (__tmp != 0)
00373 __tmp->weak_add_ref();
00374 if (_M_pi != 0)
00375 _M_pi->weak_release();
00376 _M_pi = __tmp;
00377
00378 return *this;
00379 }
00380
00381 void
00382 swap(weak_count& __r)
00383 {
00384 _Sp_counted_base * __tmp = __r._M_pi;
00385 __r._M_pi = _M_pi;
00386 _M_pi = __tmp;
00387 }
00388
00389 long
00390 use_count() const
00391 { return _M_pi != 0 ? _M_pi->use_count() : 0; }
00392
00393 friend inline bool
00394 operator==(const weak_count& __a, const weak_count& __b)
00395 { return __a._M_pi == __b._M_pi; }
00396
00397 friend inline bool
00398 operator<(const weak_count& __a, const weak_count& __b)
00399 { return std::less<_Sp_counted_base*>()(__a._M_pi, __b._M_pi); }
00400 };
00401
00402 inline
00403 shared_count::shared_count(const weak_count& __r)
00404 : _M_pi(__r._M_pi)
00405 {
00406 if (_M_pi != 0)
00407 {
00408 _M_pi->add_ref_lock();
00409 }
00410 else
00411 {
00412 __throw_bad_weak_ptr();
00413 }
00414 }
00415
00416
00417 template <typename _Tp> class weak_ptr;
00418 template <typename _Tp> class enable_shared_from_this;
00419
00420 struct __static_cast_tag {};
00421 struct __const_cast_tag {};
00422 struct __dynamic_cast_tag {};
00423 struct __polymorphic_cast_tag {};
00424
00425 template<class _Tp> struct shared_ptr_traits
00426 {
00427 typedef _Tp & reference;
00428 };
00429
00430 template<> struct shared_ptr_traits<void>
00431 {
00432 typedef void reference;
00433 };
00434
00435 template<> struct shared_ptr_traits<void const>
00436 {
00437 typedef void reference;
00438 };
00439
00440 template<> struct shared_ptr_traits<void volatile>
00441 {
00442 typedef void reference;
00443 };
00444
00445 template<> struct shared_ptr_traits<void const volatile>
00446 {
00447 typedef void reference;
00448 };
00449
00450
00451
00452
00453
00454 template <typename _Tp1, typename _Tp2>
00455 void
00456 __enable_shared_from_this( const shared_count& __pn,
00457 const enable_shared_from_this<_Tp1>* __pe,
00458 const _Tp2* __px );
00459
00460 inline void
00461 __enable_shared_from_this(const shared_count&, ...)
00462 { }
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472 template <typename _Tp>
00473 class shared_ptr
00474 {
00475 typedef typename shared_ptr_traits<_Tp>::reference _Reference;
00476
00477 public:
00478
00479 typedef _Tp element_type;
00480
00481
00482
00483
00484 shared_ptr() : _M_ptr(0), _M_refcount()
00485 { }
00486
00487
00488
00489
00490
00491
00492 template <typename _Tp1>
00493 explicit shared_ptr(_Tp1* __p)
00494 : _M_ptr(__p), _M_refcount(__p, _Sp_deleter<_Tp1>())
00495 {
00496 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00497
00498
00499 __enable_shared_from_this( _M_refcount, __p, __p );
00500 }
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 template <typename _Tp1, typename _Deleter>
00515 shared_ptr(_Tp1* __p, _Deleter __d)
00516 : _M_ptr(__p), _M_refcount(__p, __d)
00517 {
00518 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00519
00520
00521 __enable_shared_from_this( _M_refcount, __p, __p );
00522 }
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532 template <typename _Tp1>
00533 shared_ptr(const shared_ptr<_Tp1>& __r)
00534 : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
00535 {
00536 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00537 }
00538
00539
00540
00541
00542
00543
00544
00545
00546 template <typename _Tp1>
00547 explicit shared_ptr(const weak_ptr<_Tp1>& __r)
00548 : _M_refcount(__r._M_refcount)
00549 {
00550 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00551
00552
00553 _M_ptr = __r._M_ptr;
00554 }
00555
00556
00557
00558
00559 template <typename _Tp1>
00560 explicit shared_ptr(std::auto_ptr<_Tp1>& __r)
00561 : _M_ptr(__r.get()), _M_refcount()
00562 {
00563
00564
00565 _Tp1 * __tmp = __r.get();
00566 _M_refcount = shared_count(__r);
00567
00568 __enable_shared_from_this( _M_refcount, __tmp, __tmp );
00569 }
00570
00571 template <typename _Tp1>
00572 shared_ptr(const shared_ptr<_Tp1>& __r, __static_cast_tag)
00573 : _M_ptr(static_cast<element_type*>(__r._M_ptr))
00574 , _M_refcount(__r._M_refcount)
00575 { }
00576
00577 template <typename _Tp1>
00578 shared_ptr(const shared_ptr<_Tp1>& __r, __const_cast_tag)
00579 : _M_ptr(const_cast<element_type*>(__r._M_ptr))
00580 , _M_refcount(__r._M_refcount)
00581 { }
00582
00583 template <typename _Tp1>
00584 shared_ptr(const shared_ptr<_Tp1>& __r, __dynamic_cast_tag)
00585 : _M_ptr(dynamic_cast<element_type*>(__r._M_ptr))
00586 , _M_refcount(__r._M_refcount)
00587 {
00588 if (_M_ptr == 0)
00589 {
00590 _M_refcount = shared_count();
00591 }
00592 }
00593
00594 template <typename _Tp1>
00595 shared_ptr&
00596 operator=(const shared_ptr<_Tp1>& __r)
00597 {
00598 _M_ptr = __r._M_ptr;
00599 _M_refcount = __r._M_refcount;
00600 return *this;
00601 }
00602
00603 template <typename _Tp1>
00604 shared_ptr&
00605 operator=(std::auto_ptr<_Tp1>& __r)
00606 {
00607 shared_ptr(__r).swap(*this);
00608 return *this;
00609 }
00610
00611 void
00612 reset()
00613 { shared_ptr().swap(*this); }
00614
00615 template <typename _Tp1>
00616 void
00617 reset(_Tp1* __p)
00618 {
00619 _GLIBCXX_DEBUG_ASSERT(__p == 0 || __p != _M_ptr);
00620 shared_ptr(__p).swap(*this);
00621 }
00622
00623 template <typename _Tp1, typename _Deleter>
00624 void
00625 reset(_Tp1 * __p, _Deleter __d)
00626 { shared_ptr(__p, __d).swap(*this); }
00627
00628
00629 _Reference
00630 operator*() const
00631 {
00632 _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
00633 return *_M_ptr;
00634 }
00635
00636 _Tp*
00637 operator->() const
00638 {
00639 _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
00640 return _M_ptr;
00641 }
00642
00643 _Tp*
00644 get() const
00645 { return _M_ptr; }
00646
00647
00648 private:
00649 typedef _Tp* shared_ptr::*__unspecified_bool_type;
00650
00651 public:
00652 operator __unspecified_bool_type() const
00653 { return _M_ptr == 0 ? 0 : &shared_ptr::_M_ptr; }
00654
00655 bool
00656 unique() const
00657 { return _M_refcount.unique(); }
00658
00659 long
00660 use_count() const
00661 { return _M_refcount.use_count(); }
00662
00663 void
00664 swap(shared_ptr<_Tp>& __other)
00665 {
00666 std::swap(_M_ptr, __other._M_ptr);
00667 _M_refcount.swap(__other._M_refcount);
00668 }
00669
00670 private:
00671 template <typename _Tp1>
00672 bool
00673 _M_less(const shared_ptr<_Tp1>& __rhs) const
00674 { return _M_refcount < __rhs._M_refcount; }
00675
00676 void*
00677 _M_get_deleter(const std::type_info& __ti) const
00678 { return _M_refcount.get_deleter(__ti); }
00679
00680 template <typename _Tp1> friend class shared_ptr;
00681 template <typename _Tp1> friend class weak_ptr;
00682
00683
00684
00685
00686 template <typename _Del>
00687 friend inline _Del*
00688 get_deleter(const shared_ptr& __p)
00689 { return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); }
00690
00691 template <typename _Tp1>
00692 friend inline bool
00693 operator==(const shared_ptr& __a, const shared_ptr<_Tp1>& __b)
00694 { return __a.get() == __b.get(); }
00695
00696 template <typename _Tp1>
00697 friend inline bool
00698 operator!=(const shared_ptr& __a, const shared_ptr<_Tp1>& __b)
00699 { return __a.get() != __b.get(); }
00700
00701 template <typename _Tp1>
00702 friend inline bool
00703 operator<(const shared_ptr& __a, const shared_ptr<_Tp1>& __b)
00704 { return __a._M_less(__b); }
00705
00706 _Tp* _M_ptr;
00707 shared_count _M_refcount;
00708 };
00709
00710
00711
00712
00713
00714
00715
00716
00717 template <typename _Tp, typename _Tp1>
00718 shared_ptr<_Tp>
00719 static_pointer_cast(const shared_ptr<_Tp1>& __r)
00720 {
00721 return shared_ptr<_Tp>(__r, __static_cast_tag());
00722 }
00723
00724
00725
00726
00727
00728
00729 template <typename _Tp, typename _Tp1>
00730 shared_ptr<_Tp>
00731 const_pointer_cast(const shared_ptr<_Tp1>& __r)
00732 {
00733 return shared_ptr<_Tp>(__r, __const_cast_tag());
00734 }
00735
00736
00737
00738
00739
00740
00741 template <typename _Tp, typename _Tp1>
00742 shared_ptr<_Tp>
00743 dynamic_pointer_cast(const shared_ptr<_Tp1>& __r)
00744 {
00745 return shared_ptr<_Tp>(__r, __dynamic_cast_tag());
00746 }
00747
00748
00749 template <typename _Ch, typename _Tr, typename _Tp>
00750 std::basic_ostream<_Ch,_Tr>&
00751 operator<<(std::basic_ostream<_Ch,_Tr>& __os, const shared_ptr<_Tp>& __p)
00752 {
00753 __os << __p.get();
00754 return __os;
00755 }
00756
00757
00758 template <typename _Tp>
00759 class weak_ptr
00760 {
00761 public:
00762
00763 typedef _Tp element_type;
00764
00765 weak_ptr()
00766 : _M_ptr(0), _M_refcount()
00767 { }
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788 template <typename _Tp1>
00789 weak_ptr(const weak_ptr<_Tp1>& r)
00790 : _M_refcount(r._M_refcount)
00791 {
00792 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00793 _M_ptr = r.lock().get();
00794 }
00795
00796 template <typename _Tp1>
00797 weak_ptr(const shared_ptr<_Tp1>& r)
00798 : _M_ptr(r._M_ptr), _M_refcount(r._M_refcount)
00799 {
00800 __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
00801 }
00802
00803 template <typename _Tp1>
00804 weak_ptr&
00805 operator=(const weak_ptr<_Tp1>& r)
00806 {
00807 _M_ptr = r.lock().get();
00808 _M_refcount = r._M_refcount;
00809 return *this;
00810 }
00811
00812 template <typename _Tp1>
00813 weak_ptr&
00814 operator=(const shared_ptr<_Tp1>& r)
00815 {
00816 _M_ptr = r._M_ptr;
00817 _M_refcount = r._M_refcount;
00818 return *this;
00819 }
00820
00821 shared_ptr<_Tp>
00822 lock() const
00823 {
00824 #ifdef __GTHREADS
00825
00826
00827 if (expired())
00828 {
00829 return shared_ptr<element_type>();
00830 }
00831
00832 try
00833 {
00834 return shared_ptr<element_type>(*this);
00835 }
00836 catch (const bad_weak_ptr&)
00837 {
00838
00839
00840 return shared_ptr<element_type>();
00841 }
00842
00843 #else
00844
00845
00846 return expired() ? shared_ptr<element_type>() : shared_ptr<element_type>(*this);
00847
00848 #endif
00849 }
00850
00851
00852 long
00853 use_count() const
00854 { return _M_refcount.use_count(); }
00855
00856 bool
00857 expired() const
00858 { return _M_refcount.use_count() == 0; }
00859
00860 void
00861 reset()
00862 { weak_ptr().swap(*this); }
00863
00864 void
00865 swap(weak_ptr& __s)
00866 {
00867 std::swap(_M_ptr, __s._M_ptr);
00868 _M_refcount.swap(__s._M_refcount);
00869 }
00870
00871 private:
00872
00873 template <typename _Tp1>
00874 bool
00875 _M_less(const weak_ptr<_Tp1>& __rhs) const
00876 { return _M_refcount < __rhs._M_refcount; }
00877
00878
00879 void
00880 _M_assign(_Tp* __ptr, const shared_count& __refcount)
00881 {
00882 _M_ptr = __ptr;
00883 _M_refcount = __refcount;
00884 }
00885
00886
00887
00888 template <typename _Tp1>
00889 friend inline bool
00890 operator<(const weak_ptr& __lhs, const weak_ptr<_Tp1>& __rhs)
00891 { return __lhs._M_less(__rhs); }
00892
00893 template <typename _Tp1> friend class weak_ptr;
00894 template <typename _Tp1> friend class shared_ptr;
00895 friend class enable_shared_from_this<_Tp>;
00896
00897 _Tp* _M_ptr;
00898 weak_count _M_refcount;
00899
00900 };
00901
00902
00903
00904 template <typename _Tp>
00905 class enable_shared_from_this
00906 {
00907 protected:
00908
00909 enable_shared_from_this()
00910 { }
00911
00912 enable_shared_from_this(const enable_shared_from_this&)
00913 { }
00914
00915 enable_shared_from_this&
00916 operator=(const enable_shared_from_this&)
00917 { return *this; }
00918
00919 ~enable_shared_from_this()
00920 { }
00921
00922 public:
00923
00924 shared_ptr<_Tp>
00925 shared_from_this()
00926 {
00927 shared_ptr<_Tp> p(this->_M_weak_this);
00928 return p;
00929 }
00930
00931 shared_ptr<const _Tp>
00932 shared_from_this() const
00933 {
00934 shared_ptr<const _Tp> p(this->_M_weak_this);
00935 return p;
00936 }
00937
00938 private:
00939 template <typename _Tp1>
00940 void
00941 _M_weak_assign(_Tp1* __p, const shared_count& __n) const
00942 { _M_weak_this._M_assign(__p, __n); }
00943
00944 template <typename _Tp1>
00945 friend void
00946 __enable_shared_from_this( const shared_count& __pn, const enable_shared_from_this* __pe, const _Tp1* __px)
00947 {
00948 if(__pe != 0)
00949 __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
00950 }
00951
00952 mutable weak_ptr<_Tp> _M_weak_this;
00953 };
00954
00955 }
00956
00957
00958
00959
00960
00961 template <typename _Tp>
00962 inline void
00963 swap(tr1::shared_ptr<_Tp>& __a, tr1::shared_ptr<_Tp>& __b)
00964 {
00965 __a.swap(__b);
00966 }
00967
00968
00969
00970
00971
00972 template <typename _Tp>
00973 void
00974 swap(tr1::weak_ptr<_Tp>& __a, tr1::weak_ptr<_Tp>& __b)
00975 {
00976 __a.swap(__b);
00977 }
00978
00979 }
00980
00981 #endif