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>
* 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.
2011-05-18 Paolo Carlini <paolo.carlini@oracle.com>
......
......@@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// 2.2.3.10 shared_ptr get_deleter (experimental)
template<typename _Del, typename _Tp, _Lock_policy _Lp>
inline _Del*
get_deleter(const __shared_ptr<_Tp, _Lp>& __p)
get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
{
#ifdef __GXX_RTTI
return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
......@@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @brief Construct an empty %shared_ptr.
* @post use_count()==0 && get()==0
*/
constexpr shared_ptr()
constexpr shared_ptr() noexcept
: __shared_ptr<_Tp>() { }
/**
......@@ -201,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @endcode
*/
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) { }
/**
......@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp1, typename = typename
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) { }
/**
......@@ -221,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __r A %shared_ptr rvalue.
* @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)) { }
/**
......@@ -231,7 +231,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp1, typename = typename
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)) { }
/**
......@@ -261,12 +261,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __p A null pointer constant.
* @post use_count() == 0 && get() == nullptr
*/
constexpr shared_ptr(nullptr_t __p)
constexpr shared_ptr(nullptr_t __p) noexcept
: __shared_ptr<_Tp>(__p) { }
template<typename _Tp1>
shared_ptr&
operator=(const shared_ptr<_Tp1>& __r) // never throws
operator=(const shared_ptr<_Tp1>& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(__r);
return *this;
......@@ -283,7 +283,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
shared_ptr&
operator=(shared_ptr&& __r)
operator=(shared_ptr&& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
......@@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _Tp1>
shared_ptr&
operator=(shared_ptr<_Tp1>&& __r)
operator=(shared_ptr<_Tp1>&& __r) noexcept
{
this->__shared_ptr<_Tp>::operator=(std::move(__r));
return *this;
......@@ -425,23 +425,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.8.13.2.9 shared_ptr specialized algorithms.
template<typename _Tp>
inline void
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); }
// 20.8.13.2.10 shared_ptr casts.
template<typename _Tp, typename _Tp1>
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())); }
template<typename _Tp, typename _Tp1>
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())); }
template<typename _Tp, typename _Tp1>
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()))
return shared_ptr<_Tp>(__r, __p);
......@@ -458,22 +458,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class weak_ptr : public __weak_ptr<_Tp>
{
public:
constexpr weak_ptr()
constexpr weak_ptr() noexcept
: __weak_ptr<_Tp>() { }
template<typename _Tp1, typename = typename
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) { }
template<typename _Tp1, typename = typename
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) { }
template<typename _Tp1>
weak_ptr&
operator=(const weak_ptr<_Tp1>& __r) // never throws
operator=(const weak_ptr<_Tp1>& __r) noexcept
{
this->__weak_ptr<_Tp>::operator=(__r);
return *this;
......@@ -481,14 +481,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp1>
weak_ptr&
operator=(const shared_ptr<_Tp1>& __r) // never throws
operator=(const shared_ptr<_Tp1>& __r) noexcept
{
this->__weak_ptr<_Tp>::operator=(__r);
return *this;
}
shared_ptr<_Tp>
lock() const // never throws
lock() const noexcept
{
#ifdef __GTHREADS
if (this->expired())
......@@ -511,7 +511,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 20.8.13.3.7 weak_ptr specialized algorithms.
template<typename _Tp>
inline void
swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b)
swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept
{ __a.swap(__b); }
......@@ -538,12 +538,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class enable_shared_from_this
{
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&
operator=(const enable_shared_from_this&)
operator=(const enable_shared_from_this&) noexcept
{ return *this; }
~enable_shared_from_this() { }
......@@ -560,14 +560,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
template<typename _Tp1>
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); }
template<typename _Tp1>
friend void
__enable_shared_from_this_helper(const __shared_count<>& __pn,
const enable_shared_from_this* __pe,
const _Tp1* __px)
const _Tp1* __px) noexcept
{
if (__pe != 0)
__pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
......
......@@ -32,9 +32,9 @@ void test01()
{
X* px = 0;
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" }
// { dg-error "incomplete" "" { target *-*-* } 858 }
// { dg-error "incomplete" "" { target *-*-* } 862 }
}
......@@ -45,9 +45,9 @@ main()
// { dg-warning "note" "" { target *-*-* } 370 }
// { dg-warning "note" "" { target *-*-* } 365 }
// { dg-warning "note" "" { target *-*-* } 357 }
// { dg-warning "note" "" { target *-*-* } 1099 }
// { dg-warning "note" "" { target *-*-* } 1094 }
// { dg-warning "note" "" { target *-*-* } 1086 }
// { dg-warning "note" "" { target *-*-* } 1103 }
// { dg-warning "note" "" { target *-*-* } 1098 }
// { dg-warning "note" "" { target *-*-* } 1090 }
// { dg-warning "note" "" { target *-*-* } 485 }
// { dg-warning "note" "" { target *-*-* } 479 }
// { 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