shared_ptr.h: Do not swap rvalues.
2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com> * include/bits/shared_ptr.h: Do not swap rvalues. * testsuite/20_util/owner_less/cmp.cc: Add missing test variables. * testsuite/20_util/shared_ptr/comparison/cmp.cc: Likewise. * testsuite/20_util/shared_ptr/comparison/less.cc: Likewise. * testsuite/20_util/weak_ptr/observers/owner_before.cc: Likewise. * testsuite/20_util/tuple/swap.cc: Likewise. From-SVN: r148880
This commit is contained in:
parent
7326707672
commit
2ea259393d
|
@ -1,3 +1,12 @@
|
||||||
|
2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
|
* include/bits/shared_ptr.h: Do not swap rvalues.
|
||||||
|
* testsuite/20_util/owner_less/cmp.cc: Add missing test variables.
|
||||||
|
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Likewise.
|
||||||
|
* testsuite/20_util/shared_ptr/comparison/less.cc: Likewise.
|
||||||
|
* testsuite/20_util/weak_ptr/observers/owner_before.cc: Likewise.
|
||||||
|
* testsuite/20_util/tuple/swap.cc: Likewise.
|
||||||
|
|
||||||
2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com>
|
2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
* include/debug/macros.h: Replace @tbd with valid doxygen tag @todo.
|
* include/debug/macros.h: Replace @tbd with valid doxygen tag @todo.
|
||||||
|
|
|
@ -828,7 +828,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
{ 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) // never throws
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
@ -938,16 +938,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
|
swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
|
||||||
{ __a.swap(__b); }
|
{ __a.swap(__b); }
|
||||||
|
|
||||||
template<typename _Tp, _Lock_policy _Lp>
|
|
||||||
inline void
|
|
||||||
swap(__shared_ptr<_Tp, _Lp>&& __a, __shared_ptr<_Tp, _Lp>& __b)
|
|
||||||
{ __a.swap(__b); }
|
|
||||||
|
|
||||||
template<typename _Tp, _Lock_policy _Lp>
|
|
||||||
inline void
|
|
||||||
swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>&& __b)
|
|
||||||
{ __a.swap(__b); }
|
|
||||||
|
|
||||||
// 2.2.3.9 shared_ptr casts
|
// 2.2.3.9 shared_ptr casts
|
||||||
/** @warning The seemingly equivalent
|
/** @warning The seemingly equivalent
|
||||||
* <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code>
|
* <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code>
|
||||||
|
@ -1367,16 +1357,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
|
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
|
||||||
{ __a.swap(__b); }
|
{ __a.swap(__b); }
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
inline void
|
|
||||||
swap(shared_ptr<_Tp>&& __a, shared_ptr<_Tp>& __b)
|
|
||||||
{ __a.swap(__b); }
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
inline void
|
|
||||||
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>&& __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>
|
||||||
|
|
|
@ -32,16 +32,18 @@ struct B { A a[2]; };
|
||||||
int
|
int
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
// test empty shared_ptrs compare equivalent
|
bool test __attribute__((unused)) = true;
|
||||||
std::owner_less<std::shared_ptr<A>> less;
|
|
||||||
std::owner_less<std::weak_ptr<A>> wless;
|
// test empty shared_ptrs compare equivalent
|
||||||
std::shared_ptr<A> p1;
|
std::owner_less<std::shared_ptr<A>> less;
|
||||||
std::shared_ptr<A> p2;
|
std::owner_less<std::weak_ptr<A>> wless;
|
||||||
VERIFY( !less(p1, p2) && !less(p2, p1) );
|
std::shared_ptr<A> p1;
|
||||||
std::weak_ptr<A> p3;
|
std::shared_ptr<A> p2;
|
||||||
VERIFY( !less(p1, p3) && !less(p3, p1) );
|
VERIFY( !less(p1, p2) && !less(p2, p1) );
|
||||||
VERIFY( !wless(p1, p3) && !wless(p3, p1) );
|
std::weak_ptr<A> p3;
|
||||||
return 0;
|
VERIFY( !less(p1, p3) && !less(p3, p1) );
|
||||||
|
VERIFY( !wless(p1, p3) && !wless(p3, p1) );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +51,8 @@ test01()
|
||||||
int
|
int
|
||||||
test02()
|
test02()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::owner_less<std::shared_ptr<A>> less;
|
std::owner_less<std::shared_ptr<A>> less;
|
||||||
std::owner_less<std::weak_ptr<A>> wless;
|
std::owner_less<std::weak_ptr<A>> wless;
|
||||||
|
|
||||||
|
@ -80,6 +84,8 @@ test02()
|
||||||
int
|
int
|
||||||
test03()
|
test03()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::owner_less<std::shared_ptr<A>> less;
|
std::owner_less<std::shared_ptr<A>> less;
|
||||||
std::owner_less<std::weak_ptr<A>> wless;
|
std::owner_less<std::weak_ptr<A>> wless;
|
||||||
|
|
||||||
|
@ -102,6 +108,8 @@ test03()
|
||||||
int
|
int
|
||||||
test04()
|
test04()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::owner_less<std::shared_ptr<A>> less;
|
std::owner_less<std::shared_ptr<A>> less;
|
||||||
|
|
||||||
std::shared_ptr<A> a[3];
|
std::shared_ptr<A> a[3];
|
||||||
|
|
|
@ -36,13 +36,15 @@ struct B : A
|
||||||
int
|
int
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
// test empty shared_ptrs compare equivalent
|
bool test __attribute__((unused)) = true;
|
||||||
std::shared_ptr<A> p1;
|
|
||||||
std::shared_ptr<B> p2;
|
// test empty shared_ptrs compare equivalent
|
||||||
VERIFY( p1 == p2 );
|
std::shared_ptr<A> p1;
|
||||||
VERIFY( !(p1 != p2) );
|
std::shared_ptr<B> p2;
|
||||||
VERIFY( !(p1 < p2) && !(p2 < p1) );
|
VERIFY( p1 == p2 );
|
||||||
return 0;
|
VERIFY( !(p1 != p2) );
|
||||||
|
VERIFY( !(p1 < p2) && !(p2 < p1) );
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +52,8 @@ test01()
|
||||||
int
|
int
|
||||||
test02()
|
test02()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::shared_ptr<A> A_default;
|
std::shared_ptr<A> A_default;
|
||||||
|
|
||||||
std::shared_ptr<A> A_from_A(new A);
|
std::shared_ptr<A> A_from_A(new A);
|
||||||
|
@ -78,6 +82,8 @@ test02()
|
||||||
int
|
int
|
||||||
test03()
|
test03()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::shared_ptr<A> p1;
|
std::shared_ptr<A> p1;
|
||||||
|
|
||||||
// check other operators are defined
|
// check other operators are defined
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace std
|
||||||
int
|
int
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::less<std::shared_ptr<A>> less;
|
std::less<std::shared_ptr<A>> less;
|
||||||
// test empty shared_ptrs compare equivalent
|
// test empty shared_ptrs compare equivalent
|
||||||
std::shared_ptr<A> p1;
|
std::shared_ptr<A> p1;
|
||||||
|
@ -55,6 +57,8 @@ test01()
|
||||||
int
|
int
|
||||||
test02()
|
test02()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::less<std::shared_ptr<A>> less;
|
std::less<std::shared_ptr<A>> less;
|
||||||
|
|
||||||
std::shared_ptr<A> empty;
|
std::shared_ptr<A> empty;
|
||||||
|
@ -77,6 +81,8 @@ test02()
|
||||||
int
|
int
|
||||||
test03()
|
test03()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::less<std::shared_ptr<A>> less;
|
std::less<std::shared_ptr<A>> less;
|
||||||
|
|
||||||
A a;
|
A a;
|
||||||
|
|
|
@ -56,6 +56,8 @@ make_move_only (int i)
|
||||||
|
|
||||||
void test01()
|
void test01()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::tuple<> t1, t2;
|
std::tuple<> t1, t2;
|
||||||
std::swap(t1, t2);
|
std::swap(t1, t2);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ struct B { };
|
||||||
int
|
int
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
// test empty weak_ptrs compare equivalent
|
// test empty weak_ptrs compare equivalent
|
||||||
std::weak_ptr<A> p1;
|
std::weak_ptr<A> p1;
|
||||||
std::weak_ptr<B> p2;
|
std::weak_ptr<B> p2;
|
||||||
|
@ -45,6 +47,8 @@ test01()
|
||||||
int
|
int
|
||||||
test02()
|
test02()
|
||||||
{
|
{
|
||||||
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::shared_ptr<A> a0;
|
std::shared_ptr<A> a0;
|
||||||
std::weak_ptr<A> w0(a0);
|
std::weak_ptr<A> w0(a0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue