Commit cf70f97b by Jonathan Wakely Committed by Jonathan Wakely

shared_ptr_base.h: Use noexcept.

2011-05-18  Jonathan Wakely  <jwakely.gcc@gmail.com>

	* include/bits/shared_ptr_base.h: Use noexcept. Define special member
	functions as defaulted/deleted.
	* include/bits/shared_ptr.h: Use noexcept.
	* 20_util/shared_ptr/cons/43820_neg.cc: Adjust dg-error line numbers.
	* 20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.

From-SVN: r173882
parent 31f9eb59
2011-05-18 Jonathan Wakely <jwakely.gcc@gmail.com> 2011-05-18 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr_base.h: Use noexcept. Define special member
functions as defaulted/deleted.
* include/bits/shared_ptr.h: Use noexcept.
* 20_util/shared_ptr/cons/43820_neg.cc: Adjust dg-error line numbers.
* 20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
2011-05-18 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/xml/manual/bitmap_allocator.xml: Fix typos. * doc/xml/manual/bitmap_allocator.xml: Fix typos.
2011-05-18 Paolo Carlini <paolo.carlini@oracle.com> 2011-05-18 Paolo Carlini <paolo.carlini@oracle.com>
......
...@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// 2.2.3.10 shared_ptr get_deleter (experimental) /// 2.2.3.10 shared_ptr get_deleter (experimental)
template<typename _Del, typename _Tp, _Lock_policy _Lp> template<typename _Del, typename _Tp, _Lock_policy _Lp>
inline _Del* inline _Del*
get_deleter(const __shared_ptr<_Tp, _Lp>& __p) get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
{ {
#ifdef __GXX_RTTI #ifdef __GXX_RTTI
return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
...@@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @brief Construct an empty %shared_ptr. * @brief Construct an empty %shared_ptr.
* @post use_count()==0 && get()==0 * @post use_count()==0 && get()==0
*/ */
constexpr shared_ptr() constexpr shared_ptr() noexcept
: __shared_ptr<_Tp>() { } : __shared_ptr<_Tp>() { }
/** /**
...@@ -201,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -201,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @endcode * @endcode
*/ */
template<typename _Tp1> template<typename _Tp1>
shared_ptr(const shared_ptr<_Tp1>& __r, _Tp* __p) shared_ptr(const shared_ptr<_Tp1>& __r, _Tp* __p) noexcept
: __shared_ptr<_Tp>(__r, __p) { } : __shared_ptr<_Tp>(__r, __p) { }
/** /**
...@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
shared_ptr(const shared_ptr<_Tp1>& __r) shared_ptr(const shared_ptr<_Tp1>& __r) noexcept
: __shared_ptr<_Tp>(__r) { } : __shared_ptr<_Tp>(__r) { }
/** /**
...@@ -221,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -221,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __r A %shared_ptr rvalue. * @param __r A %shared_ptr rvalue.
* @post *this contains the old value of @a __r, @a __r is empty. * @post *this contains the old value of @a __r, @a __r is empty.
*/ */
shared_ptr(shared_ptr&& __r) shared_ptr(shared_ptr&& __r) noexcept
: __shared_ptr<_Tp>(std::move(__r)) { } : __shared_ptr<_Tp>(std::move(__r)) { }
/** /**
...@@ -231,7 +231,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -231,7 +231,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/ */
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
shared_ptr(shared_ptr<_Tp1>&& __r) shared_ptr(shared_ptr<_Tp1>&& __r) noexcept
: __shared_ptr<_Tp>(std::move(__r)) { } : __shared_ptr<_Tp>(std::move(__r)) { }
/** /**
...@@ -261,12 +261,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -261,12 +261,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __p A null pointer constant. * @param __p A null pointer constant.
* @post use_count() == 0 && get() == nullptr * @post use_count() == 0 && get() == nullptr
*/ */
constexpr shared_ptr(nullptr_t __p) constexpr shared_ptr(nullptr_t __p) noexcept
: __shared_ptr<_Tp>(__p) { } : __shared_ptr<_Tp>(__p) { }
template<typename _Tp1> template<typename _Tp1>
shared_ptr& shared_ptr&
operator=(const shared_ptr<_Tp1>& __r) // never throws operator=(const shared_ptr<_Tp1>& __r) noexcept
{ {
this->__shared_ptr<_Tp>::operator=(__r); this->__shared_ptr<_Tp>::operator=(__r);
return *this; return *this;
...@@ -283,7 +283,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -283,7 +283,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif #endif
shared_ptr& shared_ptr&
operator=(shared_ptr&& __r) operator=(shared_ptr&& __r) noexcept
{ {
this->__shared_ptr<_Tp>::operator=(std::move(__r)); this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this; return *this;
...@@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _Tp1> template<class _Tp1>
shared_ptr& shared_ptr&
operator=(shared_ptr<_Tp1>&& __r) operator=(shared_ptr<_Tp1>&& __r) noexcept
{ {
this->__shared_ptr<_Tp>::operator=(std::move(__r)); this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this; return *this;
...@@ -425,23 +425,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -425,23 +425,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.8.13.2.9 shared_ptr specialized algorithms. // 20.8.13.2.9 shared_ptr specialized algorithms.
template<typename _Tp> template<typename _Tp>
inline void inline void
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); } { __a.swap(__b); }
// 20.8.13.2.10 shared_ptr casts. // 20.8.13.2.10 shared_ptr casts.
template<typename _Tp, typename _Tp1> template<typename _Tp, typename _Tp1>
inline shared_ptr<_Tp> inline shared_ptr<_Tp>
static_pointer_cast(const shared_ptr<_Tp1>& __r) static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
{ return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); } { return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); }
template<typename _Tp, typename _Tp1> template<typename _Tp, typename _Tp1>
inline shared_ptr<_Tp> inline shared_ptr<_Tp>
const_pointer_cast(const shared_ptr<_Tp1>& __r) const_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
{ return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); } { return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); }
template<typename _Tp, typename _Tp1> template<typename _Tp, typename _Tp1>
inline shared_ptr<_Tp> inline shared_ptr<_Tp>
dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
{ {
if (_Tp* __p = dynamic_cast<_Tp*>(__r.get())) if (_Tp* __p = dynamic_cast<_Tp*>(__r.get()))
return shared_ptr<_Tp>(__r, __p); return shared_ptr<_Tp>(__r, __p);
...@@ -458,22 +458,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -458,22 +458,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class weak_ptr : public __weak_ptr<_Tp> class weak_ptr : public __weak_ptr<_Tp>
{ {
public: public:
constexpr weak_ptr() constexpr weak_ptr() noexcept
: __weak_ptr<_Tp>() { } : __weak_ptr<_Tp>() { }
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
weak_ptr(const weak_ptr<_Tp1>& __r) weak_ptr(const weak_ptr<_Tp1>& __r) noexcept
: __weak_ptr<_Tp>(__r) { } : __weak_ptr<_Tp>(__r) { }
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
weak_ptr(const shared_ptr<_Tp1>& __r) weak_ptr(const shared_ptr<_Tp1>& __r) noexcept
: __weak_ptr<_Tp>(__r) { } : __weak_ptr<_Tp>(__r) { }
template<typename _Tp1> template<typename _Tp1>
weak_ptr& weak_ptr&
operator=(const weak_ptr<_Tp1>& __r) // never throws operator=(const weak_ptr<_Tp1>& __r) noexcept
{ {
this->__weak_ptr<_Tp>::operator=(__r); this->__weak_ptr<_Tp>::operator=(__r);
return *this; return *this;
...@@ -481,14 +481,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -481,14 +481,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp1> template<typename _Tp1>
weak_ptr& weak_ptr&
operator=(const shared_ptr<_Tp1>& __r) // never throws operator=(const shared_ptr<_Tp1>& __r) noexcept
{ {
this->__weak_ptr<_Tp>::operator=(__r); this->__weak_ptr<_Tp>::operator=(__r);
return *this; return *this;
} }
shared_ptr<_Tp> shared_ptr<_Tp>
lock() const // never throws lock() const noexcept
{ {
#ifdef __GTHREADS #ifdef __GTHREADS
if (this->expired()) if (this->expired())
...@@ -511,7 +511,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -511,7 +511,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.8.13.3.7 weak_ptr specialized algorithms. // 20.8.13.3.7 weak_ptr specialized algorithms.
template<typename _Tp> template<typename _Tp>
inline void inline void
swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); } { __a.swap(__b); }
...@@ -538,12 +538,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -538,12 +538,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class enable_shared_from_this class enable_shared_from_this
{ {
protected: protected:
constexpr enable_shared_from_this() { } constexpr enable_shared_from_this() noexcept { }
enable_shared_from_this(const enable_shared_from_this&) { } enable_shared_from_this(const enable_shared_from_this&) noexcept { }
enable_shared_from_this& enable_shared_from_this&
operator=(const enable_shared_from_this&) operator=(const enable_shared_from_this&) noexcept
{ return *this; } { return *this; }
~enable_shared_from_this() { } ~enable_shared_from_this() { }
...@@ -560,14 +560,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -560,14 +560,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private: private:
template<typename _Tp1> template<typename _Tp1>
void void
_M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept
{ _M_weak_this._M_assign(__p, __n); } { _M_weak_this._M_assign(__p, __n); }
template<typename _Tp1> template<typename _Tp1>
friend void friend void
__enable_shared_from_this_helper(const __shared_count<>& __pn, __enable_shared_from_this_helper(const __shared_count<>& __pn,
const enable_shared_from_this* __pe, const enable_shared_from_this* __pe,
const _Tp1* __px) const _Tp1* __px) noexcept
{ {
if (__pe != 0) if (__pe != 0)
__pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
......
...@@ -61,7 +61,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -61,7 +61,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
virtual char const* virtual char const*
what() const throw(); what() const noexcept;
virtual ~bad_weak_ptr() throw(); virtual ~bad_weak_ptr() throw();
}; };
...@@ -108,21 +108,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -108,21 +108,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public _Mutex_base<_Lp> : public _Mutex_base<_Lp>
{ {
public: public:
_Sp_counted_base() _Sp_counted_base() noexcept
: _M_use_count(1), _M_weak_count(1) { } : _M_use_count(1), _M_weak_count(1) { }
virtual virtual
~_Sp_counted_base() // nothrow ~_Sp_counted_base() noexcept
{ } { }
// Called when _M_use_count drops to zero, to release the resources // Called when _M_use_count drops to zero, to release the resources
// managed by *this. // managed by *this.
virtual void virtual void
_M_dispose() = 0; // nothrow _M_dispose() noexcept = 0;
// Called when _M_weak_count drops to zero. // Called when _M_weak_count drops to zero.
virtual void virtual void
_M_destroy() // nothrow _M_destroy() noexcept
{ delete this; } { delete this; }
virtual void* virtual void*
...@@ -136,7 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -136,7 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_add_ref_lock(); _M_add_ref_lock();
void void
_M_release() // nothrow _M_release() noexcept
{ {
// Be race-detector-friendly. For more info see bits/c++config. // Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count);
...@@ -166,11 +166,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -166,11 +166,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
void void
_M_weak_add_ref() // nothrow _M_weak_add_ref() noexcept
{ __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); }
void void
_M_weak_release() // nothrow _M_weak_release() noexcept
{ {
// Be race-detector-friendly. For more info see bits/c++config. // Be race-detector-friendly. For more info see bits/c++config.
_GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count);
...@@ -189,7 +189,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -189,7 +189,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
long long
_M_get_use_count() const // nothrow _M_get_use_count() const noexcept
{ {
// No memory barrier is used here so there is no synchronization // No memory barrier is used here so there is no synchronization
// with other threads. // with other threads.
...@@ -197,8 +197,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -197,8 +197,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
private: private:
_Sp_counted_base(_Sp_counted_base const&); _Sp_counted_base(_Sp_counted_base const&) = delete;
_Sp_counted_base& operator=(_Sp_counted_base const&); _Sp_counted_base& operator=(_Sp_counted_base const&) = delete;
_Atomic_word _M_use_count; // #shared _Atomic_word _M_use_count; // #shared
_Atomic_word _M_weak_count; // #weak + (#shared != 0) _Atomic_word _M_weak_count; // #weak + (#shared != 0)
...@@ -289,11 +289,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -289,11 +289,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_ptr(__p) { } : _M_ptr(__p) { }
virtual void virtual void
_M_dispose() // nothrow _M_dispose() noexcept
{ delete _M_ptr; } { delete _M_ptr; }
virtual void virtual void
_M_destroy() // nothrow _M_destroy() noexcept
{ delete this; } { delete this; }
virtual void* virtual void*
...@@ -309,15 +309,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -309,15 +309,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<> template<>
inline void inline void
_Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() { } _Sp_counted_ptr<nullptr_t, _S_single>::_M_dispose() noexcept { }
template<> template<>
inline void inline void
_Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() { } _Sp_counted_ptr<nullptr_t, _S_mutex>::_M_dispose() noexcept { }
template<> template<>
inline void inline void
_Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() { } _Sp_counted_ptr<nullptr_t, _S_atomic>::_M_dispose() noexcept { }
// Support for custom deleter and/or allocator // Support for custom deleter and/or allocator
template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp> template<typename _Ptr, typename _Deleter, typename _Alloc, _Lock_policy _Lp>
...@@ -347,11 +347,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -347,11 +347,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_ptr(__p), _M_del(__d, __a) { } : _M_ptr(__p), _M_del(__d, __a) { }
virtual void virtual void
_M_dispose() // nothrow _M_dispose() noexcept
{ _M_del._M_del(_M_ptr); } { _M_del._M_del(_M_ptr); }
virtual void virtual void
_M_destroy() // nothrow _M_destroy() noexcept
{ {
_My_alloc_type __a(_M_del); _My_alloc_type __a(_M_del);
this->~_Sp_counted_deleter(); this->~_Sp_counted_deleter();
...@@ -413,7 +413,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -413,7 +413,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Override because the allocator needs to know the dynamic type // Override because the allocator needs to know the dynamic type
virtual void virtual void
_M_destroy() // nothrow _M_destroy() noexcept
{ {
typedef typename _Alloc::template typedef typename _Alloc::template
rebind<_Sp_counted_ptr_inplace>::other _My_alloc_type; rebind<_Sp_counted_ptr_inplace>::other _My_alloc_type;
...@@ -424,7 +424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -424,7 +424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Sneaky trick so __shared_ptr can get the managed pointer // Sneaky trick so __shared_ptr can get the managed pointer
virtual void* virtual void*
_M_get_deleter(const std::type_info& __ti) _M_get_deleter(const std::type_info& __ti) noexcept
{ {
#ifdef __GXX_RTTI #ifdef __GXX_RTTI
return __ti == typeid(_Sp_make_shared_tag) return __ti == typeid(_Sp_make_shared_tag)
...@@ -444,7 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -444,7 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __shared_count class __shared_count
{ {
public: public:
constexpr __shared_count() : _M_pi(0) // nothrow constexpr __shared_count() noexcept : _M_pi(0)
{ } { }
template<typename _Ptr> template<typename _Ptr>
...@@ -545,21 +545,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -545,21 +545,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Throw bad_weak_ptr when __r._M_get_use_count() == 0. // Throw bad_weak_ptr when __r._M_get_use_count() == 0.
explicit __shared_count(const __weak_count<_Lp>& __r); explicit __shared_count(const __weak_count<_Lp>& __r);
~__shared_count() // nothrow ~__shared_count() noexcept
{ {
if (_M_pi != 0) if (_M_pi != 0)
_M_pi->_M_release(); _M_pi->_M_release();
} }
__shared_count(const __shared_count& __r) __shared_count(const __shared_count& __r) noexcept
: _M_pi(__r._M_pi) // nothrow : _M_pi(__r._M_pi)
{ {
if (_M_pi != 0) if (_M_pi != 0)
_M_pi->_M_add_ref_copy(); _M_pi->_M_add_ref_copy();
} }
__shared_count& __shared_count&
operator=(const __shared_count& __r) // nothrow operator=(const __shared_count& __r) noexcept
{ {
_Sp_counted_base<_Lp>* __tmp = __r._M_pi; _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
if (__tmp != _M_pi) if (__tmp != _M_pi)
...@@ -574,7 +574,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -574,7 +574,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
void void
_M_swap(__shared_count& __r) // nothrow _M_swap(__shared_count& __r) noexcept
{ {
_Sp_counted_base<_Lp>* __tmp = __r._M_pi; _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
__r._M_pi = _M_pi; __r._M_pi = _M_pi;
...@@ -582,28 +582,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -582,28 +582,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
long long
_M_get_use_count() const // nothrow _M_get_use_count() const noexcept
{ return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; } { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
bool bool
_M_unique() const // nothrow _M_unique() const noexcept
{ return this->_M_get_use_count() == 1; } { return this->_M_get_use_count() == 1; }
void* void*
_M_get_deleter(const std::type_info& __ti) const _M_get_deleter(const std::type_info& __ti) const noexcept
{ return _M_pi ? _M_pi->_M_get_deleter(__ti) : 0; } { return _M_pi ? _M_pi->_M_get_deleter(__ti) : 0; }
bool bool
_M_less(const __shared_count& __rhs) const _M_less(const __shared_count& __rhs) const noexcept
{ return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); }
bool bool
_M_less(const __weak_count<_Lp>& __rhs) const _M_less(const __weak_count<_Lp>& __rhs) const noexcept
{ return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); }
// Friend function injected into enclosing namespace and found by ADL // Friend function injected into enclosing namespace and found by ADL
friend inline bool friend inline bool
operator==(const __shared_count& __a, const __shared_count& __b) operator==(const __shared_count& __a, const __shared_count& __b) noexcept
{ return __a._M_pi == __b._M_pi; } { return __a._M_pi == __b._M_pi; }
private: private:
...@@ -637,29 +637,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -637,29 +637,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __weak_count class __weak_count
{ {
public: public:
constexpr __weak_count() : _M_pi(0) // nothrow constexpr __weak_count() noexcept : _M_pi(0)
{ } { }
__weak_count(const __shared_count<_Lp>& __r) : _M_pi(__r._M_pi) // nothrow __weak_count(const __shared_count<_Lp>& __r) noexcept
: _M_pi(__r._M_pi)
{ {
if (_M_pi != 0) if (_M_pi != 0)
_M_pi->_M_weak_add_ref(); _M_pi->_M_weak_add_ref();
} }
__weak_count(const __weak_count<_Lp>& __r) : _M_pi(__r._M_pi) // nothrow __weak_count(const __weak_count<_Lp>& __r) noexcept
: _M_pi(__r._M_pi)
{ {
if (_M_pi != 0) if (_M_pi != 0)
_M_pi->_M_weak_add_ref(); _M_pi->_M_weak_add_ref();
} }
~__weak_count() // nothrow ~__weak_count() noexcept
{ {
if (_M_pi != 0) if (_M_pi != 0)
_M_pi->_M_weak_release(); _M_pi->_M_weak_release();
} }
__weak_count<_Lp>& __weak_count<_Lp>&
operator=(const __shared_count<_Lp>& __r) // nothrow operator=(const __shared_count<_Lp>& __r) noexcept
{ {
_Sp_counted_base<_Lp>* __tmp = __r._M_pi; _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
if (__tmp != 0) if (__tmp != 0)
...@@ -671,7 +673,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -671,7 +673,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
__weak_count<_Lp>& __weak_count<_Lp>&
operator=(const __weak_count<_Lp>& __r) // nothrow operator=(const __weak_count<_Lp>& __r) noexcept
{ {
_Sp_counted_base<_Lp>* __tmp = __r._M_pi; _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
if (__tmp != 0) if (__tmp != 0)
...@@ -683,7 +685,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -683,7 +685,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
void void
_M_swap(__weak_count<_Lp>& __r) // nothrow _M_swap(__weak_count<_Lp>& __r) noexcept
{ {
_Sp_counted_base<_Lp>* __tmp = __r._M_pi; _Sp_counted_base<_Lp>* __tmp = __r._M_pi;
__r._M_pi = _M_pi; __r._M_pi = _M_pi;
...@@ -691,20 +693,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -691,20 +693,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
long long
_M_get_use_count() const // nothrow _M_get_use_count() const noexcept
{ return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; } { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
bool bool
_M_less(const __weak_count& __rhs) const _M_less(const __weak_count& __rhs) const noexcept
{ return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); }
bool bool
_M_less(const __shared_count<_Lp>& __rhs) const _M_less(const __shared_count<_Lp>& __rhs) const noexcept
{ return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); }
// Friend function injected into enclosing namespace and found by ADL // Friend function injected into enclosing namespace and found by ADL
friend inline bool friend inline bool
operator==(const __weak_count& __a, const __weak_count& __b) operator==(const __weak_count& __a, const __weak_count& __b) noexcept
{ return __a._M_pi == __b._M_pi; } { return __a._M_pi == __b._M_pi; }
private: private:
...@@ -732,18 +734,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -732,18 +734,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void void
__enable_shared_from_this_helper(const __shared_count<_Lp>&, __enable_shared_from_this_helper(const __shared_count<_Lp>&,
const __enable_shared_from_this<_Tp1, const __enable_shared_from_this<_Tp1,
_Lp>*, const _Tp2*); _Lp>*, const _Tp2*) noexcept;
// Friend of enable_shared_from_this. // Friend of enable_shared_from_this.
template<typename _Tp1, typename _Tp2> template<typename _Tp1, typename _Tp2>
void void
__enable_shared_from_this_helper(const __shared_count<>&, __enable_shared_from_this_helper(const __shared_count<>&,
const enable_shared_from_this<_Tp1>*, const enable_shared_from_this<_Tp1>*,
const _Tp2*); const _Tp2*) noexcept;
template<_Lock_policy _Lp> template<_Lock_policy _Lp>
inline void inline void
__enable_shared_from_this_helper(const __shared_count<_Lp>&, ...) __enable_shared_from_this_helper(const __shared_count<_Lp>&, ...) noexcept
{ } { }
...@@ -753,8 +755,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -753,8 +755,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public: public:
typedef _Tp element_type; typedef _Tp element_type;
constexpr __shared_ptr() constexpr __shared_ptr() noexcept
: _M_ptr(0), _M_refcount() // never throws : _M_ptr(0), _M_refcount()
{ } { }
template<typename _Tp1> template<typename _Tp1>
...@@ -795,20 +797,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -795,20 +797,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ } { }
template<typename _Tp1> template<typename _Tp1>
__shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, _Tp* __p) __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r, _Tp* __p) noexcept
: _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws : _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws
{ } { }
// generated copy constructor, assignment, destructor are fine. __shared_ptr(const __shared_ptr&) noexcept = default;
__shared_ptr& operator=(const __shared_ptr&) noexcept = default;
~__shared_ptr() = default;
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
__shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r) __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
: _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
{ } { }
__shared_ptr(__shared_ptr&& __r) __shared_ptr(__shared_ptr&& __r) noexcept
: _M_ptr(__r._M_ptr), _M_refcount() // never throws : _M_ptr(__r._M_ptr), _M_refcount()
{ {
_M_refcount._M_swap(__r._M_refcount); _M_refcount._M_swap(__r._M_refcount);
__r._M_ptr = 0; __r._M_ptr = 0;
...@@ -816,8 +820,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -816,8 +820,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
__shared_ptr(__shared_ptr<_Tp1, _Lp>&& __r) __shared_ptr(__shared_ptr<_Tp1, _Lp>&& __r) noexcept
: _M_ptr(__r._M_ptr), _M_refcount() // never throws : _M_ptr(__r._M_ptr), _M_refcount()
{ {
_M_refcount._M_swap(__r._M_refcount); _M_refcount._M_swap(__r._M_refcount);
__r._M_ptr = 0; __r._M_ptr = 0;
...@@ -860,13 +864,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -860,13 +864,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif #endif
/* TODO: use delegating constructor */ /* TODO: use delegating constructor */
constexpr __shared_ptr(nullptr_t) constexpr __shared_ptr(nullptr_t) noexcept
: _M_ptr(0), _M_refcount() // never throws : _M_ptr(0), _M_refcount()
{ } { }
template<typename _Tp1> template<typename _Tp1>
__shared_ptr& __shared_ptr&
operator=(const __shared_ptr<_Tp1, _Lp>& __r) // never throws operator=(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
{ {
_M_ptr = __r._M_ptr; _M_ptr = __r._M_ptr;
_M_refcount = __r._M_refcount; // __shared_count::op= doesn't throw _M_refcount = __r._M_refcount; // __shared_count::op= doesn't throw
...@@ -884,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -884,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif #endif
__shared_ptr& __shared_ptr&
operator=(__shared_ptr&& __r) operator=(__shared_ptr&& __r) noexcept
{ {
__shared_ptr(std::move(__r)).swap(*this); __shared_ptr(std::move(__r)).swap(*this);
return *this; return *this;
...@@ -892,7 +896,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -892,7 +896,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _Tp1> template<class _Tp1>
__shared_ptr& __shared_ptr&
operator=(__shared_ptr<_Tp1, _Lp>&& __r) operator=(__shared_ptr<_Tp1, _Lp>&& __r) noexcept
{ {
__shared_ptr(std::move(__r)).swap(*this); __shared_ptr(std::move(__r)).swap(*this);
return *this; return *this;
...@@ -907,7 +911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -907,7 +911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
void void
reset() // never throws reset() noexcept
{ __shared_ptr().swap(*this); } { __shared_ptr().swap(*this); }
template<typename _Tp1> template<typename _Tp1>
...@@ -931,36 +935,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -931,36 +935,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Allow class instantiation when _Tp is [cv-qual] void. // Allow class instantiation when _Tp is [cv-qual] void.
typename std::add_lvalue_reference<_Tp>::type typename std::add_lvalue_reference<_Tp>::type
operator*() const // never throws operator*() const noexcept
{ {
_GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
return *_M_ptr; return *_M_ptr;
} }
_Tp* _Tp*
operator->() const // never throws operator->() const noexcept
{ {
_GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
return _M_ptr; return _M_ptr;
} }
_Tp* _Tp*
get() const // never throws get() const noexcept
{ return _M_ptr; } { return _M_ptr; }
explicit operator bool() const // never throws explicit operator bool() const // never throws
{ return _M_ptr == 0 ? false : true; } { return _M_ptr == 0 ? false : true; }
bool bool
unique() const // never throws unique() const noexcept
{ return _M_refcount._M_unique(); } { return _M_refcount._M_unique(); }
long long
use_count() const // never throws use_count() const noexcept
{ return _M_refcount._M_get_use_count(); } { return _M_refcount._M_get_use_count(); }
void void
swap(__shared_ptr<_Tp, _Lp>& __other) // never throws swap(__shared_ptr<_Tp, _Lp>& __other) noexcept
{ {
std::swap(_M_ptr, __other._M_ptr); std::swap(_M_ptr, __other._M_ptr);
_M_refcount._M_swap(__other._M_refcount); _M_refcount._M_swap(__other._M_refcount);
...@@ -1033,14 +1037,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1033,14 +1037,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private: private:
void* void*
_M_get_deleter(const std::type_info& __ti) const _M_get_deleter(const std::type_info& __ti) const noexcept
{ return _M_refcount._M_get_deleter(__ti); } { return _M_refcount._M_get_deleter(__ti); }
template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr; template<typename _Tp1, _Lock_policy _Lp1> friend class __shared_ptr;
template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr; template<typename _Tp1, _Lock_policy _Lp1> friend class __weak_ptr;
template<typename _Del, typename _Tp1, _Lock_policy _Lp1> template<typename _Del, typename _Tp1, _Lock_policy _Lp1>
friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&); friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept;
_Tp* _M_ptr; // Contained pointer. _Tp* _M_ptr; // Contained pointer.
__shared_count<_Lp> _M_refcount; // Reference counter. __shared_count<_Lp> _M_refcount; // Reference counter.
...@@ -1151,7 +1155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1151,7 +1155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct _Sp_less : public binary_function<_Sp, _Sp, bool> struct _Sp_less : public binary_function<_Sp, _Sp, bool>
{ {
bool bool
operator()(const _Sp& __lhs, const _Sp& __rhs) const operator()(const _Sp& __lhs, const _Sp& __rhs) const noexcept
{ {
typedef typename _Sp::element_type element_type; typedef typename _Sp::element_type element_type;
return std::less<element_type*>()(__lhs.get(), __rhs.get()); return std::less<element_type*>()(__lhs.get(), __rhs.get());
...@@ -1166,7 +1170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1166,7 +1170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 2.2.3.8 shared_ptr specialized algorithms. // 2.2.3.8 shared_ptr specialized algorithms.
template<typename _Tp, _Lock_policy _Lp> template<typename _Tp, _Lock_policy _Lp>
inline void inline void
swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
{ __a.swap(__b); } { __a.swap(__b); }
// 2.2.3.9 shared_ptr casts // 2.2.3.9 shared_ptr casts
...@@ -1178,7 +1182,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1178,7 +1182,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// static_pointer_cast /// static_pointer_cast
template<typename _Tp, typename _Tp1, _Lock_policy _Lp> template<typename _Tp, typename _Tp1, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp> inline __shared_ptr<_Tp, _Lp>
static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
{ return __shared_ptr<_Tp, _Lp>(__r, static_cast<_Tp*>(__r.get())); } { return __shared_ptr<_Tp, _Lp>(__r, static_cast<_Tp*>(__r.get())); }
// The seemingly equivalent code: // The seemingly equivalent code:
...@@ -1188,7 +1192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1188,7 +1192,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// const_pointer_cast /// const_pointer_cast
template<typename _Tp, typename _Tp1, _Lock_policy _Lp> template<typename _Tp, typename _Tp1, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp> inline __shared_ptr<_Tp, _Lp>
const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
{ return __shared_ptr<_Tp, _Lp>(__r, const_cast<_Tp*>(__r.get())); } { return __shared_ptr<_Tp, _Lp>(__r, const_cast<_Tp*>(__r.get())); }
// The seemingly equivalent code: // The seemingly equivalent code:
...@@ -1198,7 +1202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1198,7 +1202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// dynamic_pointer_cast /// dynamic_pointer_cast
template<typename _Tp, typename _Tp1, _Lock_policy _Lp> template<typename _Tp, typename _Tp1, _Lock_policy _Lp>
inline __shared_ptr<_Tp, _Lp> inline __shared_ptr<_Tp, _Lp>
dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
{ {
if (_Tp* __p = dynamic_cast<_Tp*>(__r.get())) if (_Tp* __p = dynamic_cast<_Tp*>(__r.get()))
return __shared_ptr<_Tp, _Lp>(__r, __p); return __shared_ptr<_Tp, _Lp>(__r, __p);
...@@ -1212,11 +1216,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1212,11 +1216,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public: public:
typedef _Tp element_type; typedef _Tp element_type;
constexpr __weak_ptr() constexpr __weak_ptr() noexcept
: _M_ptr(0), _M_refcount() // never throws : _M_ptr(0), _M_refcount()
{ } { }
// Generated copy constructor, assignment, destructor are fine. __weak_ptr(const __weak_ptr&) noexcept = default;
__weak_ptr& operator=(const __weak_ptr&) noexcept = default;
~__weak_ptr() = default;
// The "obvious" converting constructor implementation: // The "obvious" converting constructor implementation:
// //
...@@ -1234,19 +1240,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1234,19 +1240,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// in multithreaded programs __r._M_ptr may be invalidated at any point. // in multithreaded programs __r._M_ptr may be invalidated at any point.
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
__weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) __weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) noexcept
: _M_refcount(__r._M_refcount) // never throws : _M_refcount(__r._M_refcount)
{ _M_ptr = __r.lock().get(); } { _M_ptr = __r.lock().get(); }
template<typename _Tp1, typename = typename template<typename _Tp1, typename = typename
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type> std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
__weak_ptr(const __shared_ptr<_Tp1, _Lp>& __r) __weak_ptr(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
: _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
{ } { }
template<typename _Tp1> template<typename _Tp1>
__weak_ptr& __weak_ptr&
operator=(const __weak_ptr<_Tp1, _Lp>& __r) // never throws operator=(const __weak_ptr<_Tp1, _Lp>& __r) noexcept
{ {
_M_ptr = __r.lock().get(); _M_ptr = __r.lock().get();
_M_refcount = __r._M_refcount; _M_refcount = __r._M_refcount;
...@@ -1255,7 +1261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1255,7 +1261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp1> template<typename _Tp1>
__weak_ptr& __weak_ptr&
operator=(const __shared_ptr<_Tp1, _Lp>& __r) // never throws operator=(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
{ {
_M_ptr = __r._M_ptr; _M_ptr = __r._M_ptr;
_M_refcount = __r._M_refcount; _M_refcount = __r._M_refcount;
...@@ -1263,7 +1269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1263,7 +1269,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
__shared_ptr<_Tp, _Lp> __shared_ptr<_Tp, _Lp>
lock() const // never throws lock() const noexcept
{ {
#ifdef __GTHREADS #ifdef __GTHREADS
// Optimization: avoid throw overhead. // Optimization: avoid throw overhead.
...@@ -1291,11 +1297,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1291,11 +1297,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} // XXX MT } // XXX MT
long long
use_count() const // never throws use_count() const noexcept
{ return _M_refcount._M_get_use_count(); } { return _M_refcount._M_get_use_count(); }
bool bool
expired() const // never throws expired() const noexcept
{ return _M_refcount._M_get_use_count() == 0; } { return _M_refcount._M_get_use_count() == 0; }
template<typename _Tp1> template<typename _Tp1>
...@@ -1309,11 +1315,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1309,11 +1315,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_refcount._M_less(__rhs._M_refcount); } { return _M_refcount._M_less(__rhs._M_refcount); }
void void
reset() // never throws reset() noexcept
{ __weak_ptr().swap(*this); } { __weak_ptr().swap(*this); }
void void
swap(__weak_ptr& __s) // never throws swap(__weak_ptr& __s) noexcept
{ {
std::swap(_M_ptr, __s._M_ptr); std::swap(_M_ptr, __s._M_ptr);
_M_refcount._M_swap(__s._M_refcount); _M_refcount._M_swap(__s._M_refcount);
...@@ -1322,7 +1328,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1322,7 +1328,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private: private:
// Used by __enable_shared_from_this. // Used by __enable_shared_from_this.
void void
_M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept
{ {
_M_ptr = __ptr; _M_ptr = __ptr;
_M_refcount = __refcount; _M_refcount = __refcount;
...@@ -1340,7 +1346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1340,7 +1346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.8.13.3.7 weak_ptr specialized algorithms. // 20.8.13.3.7 weak_ptr specialized algorithms.
template<typename _Tp, _Lock_policy _Lp> template<typename _Tp, _Lock_policy _Lp>
inline void inline void
swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
{ __a.swap(__b); } { __a.swap(__b); }
template<typename _Tp, typename _Tp1> template<typename _Tp, typename _Tp1>
...@@ -1374,12 +1380,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1374,12 +1380,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __enable_shared_from_this class __enable_shared_from_this
{ {
protected: protected:
constexpr __enable_shared_from_this() { } constexpr __enable_shared_from_this() noexcept { }
__enable_shared_from_this(const __enable_shared_from_this&) { } __enable_shared_from_this(const __enable_shared_from_this&) noexcept { }
__enable_shared_from_this& __enable_shared_from_this&
operator=(const __enable_shared_from_this&) operator=(const __enable_shared_from_this&) noexcept
{ return *this; } { return *this; }
~__enable_shared_from_this() { } ~__enable_shared_from_this() { }
...@@ -1396,14 +1402,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1396,14 +1402,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private: private:
template<typename _Tp1> template<typename _Tp1>
void void
_M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept
{ _M_weak_this._M_assign(__p, __n); } { _M_weak_this._M_assign(__p, __n); }
template<typename _Tp1> template<typename _Tp1>
friend void friend void
__enable_shared_from_this_helper(const __shared_count<_Lp>& __pn, __enable_shared_from_this_helper(const __shared_count<_Lp>& __pn,
const __enable_shared_from_this* __pe, const __enable_shared_from_this* __pe,
const _Tp1* __px) const _Tp1* __px) noexcept
{ {
if (__pe != 0) if (__pe != 0)
__pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn); __pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
......
...@@ -32,9 +32,9 @@ void test01() ...@@ -32,9 +32,9 @@ void test01()
{ {
X* px = 0; X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" } std::shared_ptr<X> p1(px); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 766 } // { dg-error "incomplete" "" { target *-*-* } 768 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" } std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 858 } // { dg-error "incomplete" "" { target *-*-* } 862 }
} }
...@@ -45,9 +45,9 @@ main() ...@@ -45,9 +45,9 @@ main()
// { dg-warning "note" "" { target *-*-* } 370 } // { dg-warning "note" "" { target *-*-* } 370 }
// { dg-warning "note" "" { target *-*-* } 365 } // { dg-warning "note" "" { target *-*-* } 365 }
// { dg-warning "note" "" { target *-*-* } 357 } // { dg-warning "note" "" { target *-*-* } 357 }
// { dg-warning "note" "" { target *-*-* } 1099 } // { dg-warning "note" "" { target *-*-* } 1103 }
// { dg-warning "note" "" { target *-*-* } 1094 } // { dg-warning "note" "" { target *-*-* } 1098 }
// { dg-warning "note" "" { target *-*-* } 1086 } // { dg-warning "note" "" { target *-*-* } 1090 }
// { dg-warning "note" "" { target *-*-* } 485 } // { dg-warning "note" "" { target *-*-* } 485 }
// { dg-warning "note" "" { target *-*-* } 479 } // { dg-warning "note" "" { target *-*-* } 479 }
// { dg-warning "note" "" { target *-*-* } 469 } // { dg-warning "note" "" { target *-*-* } 469 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment