aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2010-12-06 18:37:00 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-12-06 18:37:00 +0000
commit403b89a8748380041c49f82d1ad7dee67a4e4255 (patch)
treeb9e903cb6d869e8a11d09c4485cbd07e3f658272
parent1cd7d53fc3b9b2b747195874f584b3405299e62d (diff)
downloadgcc-403b89a8748380041c49f82d1ad7dee67a4e4255.zip
gcc-403b89a8748380041c49f82d1ad7dee67a4e4255.tar.gz
gcc-403b89a8748380041c49f82d1ad7dee67a4e4255.tar.bz2
shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter, const _Alloc&), [...]): Take the allocator by value, per N3225.
2010-12-06 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter, const _Alloc&), shared_ptr(nullptr_t, _Deleter, const _Alloc&)): Take the allocator by value, per N3225. (shared_ptr<>::shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...), allocate_shared(_Alloc, _Args&&...): Viceversa, take the allocator by const lvalue ref. * include/bits/shared_ptr_base.h (__shared_count<>:: __shared_count(_Sp_make_shared_tag, _Tp*, _Alloc, _Args&&...), __shared_ptr<>::__shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...), __allocate_shared(_Alloc, _Args&&...)): Likewise. (__shared_ptr<>::__shared_ptr(_Tp1*, _Deleter, const _Alloc&), __shared_ptr(nullptr_t, _Deleter, const _Alloc&), reset(_Tp1*, _Deleter, const _Alloc&)): Take the allocator by value. * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust dg-error line numbers. * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise. From-SVN: r167510
-rw-r--r--libstdc++-v3/ChangeLog19
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h20
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h31
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc4
-rw-r--r--libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc4
5 files changed, 51 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d9cdfb3..410743e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter,
+ const _Alloc&), shared_ptr(nullptr_t, _Deleter, const _Alloc&)): Take
+ the allocator by value, per N3225.
+ (shared_ptr<>::shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...),
+ allocate_shared(_Alloc, _Args&&...): Viceversa, take the allocator
+ by const lvalue ref.
+ * include/bits/shared_ptr_base.h (__shared_count<>::
+ __shared_count(_Sp_make_shared_tag, _Tp*, _Alloc, _Args&&...),
+ __shared_ptr<>::__shared_ptr(_Sp_make_shared_tag, _Alloc, _Args&&...),
+ __allocate_shared(_Alloc, _Args&&...)): Likewise.
+ (__shared_ptr<>::__shared_ptr(_Tp1*, _Deleter, const _Alloc&),
+ __shared_ptr(nullptr_t, _Deleter, const _Alloc&), reset(_Tp1*,
+ _Deleter, const _Alloc&)): Take the allocator by value.
+ * testsuite/20_util/shared_ptr/cons/43820.cc: Adjust dg-error line
+ numbers.
+ * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
+
2010-12-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* acinclude.m4 (symvers_renaming): Also set if enable_symvers = no.
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 0e6f7a6..6dc9c9f 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -122,7 +122,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* __shared_ptr will release __p by calling __d(__p)
*/
template<typename _Tp1, typename _Deleter>
- shared_ptr(_Tp1* __p, _Deleter __d) : __shared_ptr<_Tp>(__p, __d) { }
+ shared_ptr(_Tp1* __p, _Deleter __d)
+ : __shared_ptr<_Tp>(__p, __d) { }
/**
* @brief Construct a %shared_ptr that owns a null pointer
@@ -157,8 +158,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* __shared_ptr will release __p by calling __d(__p)
*/
template<typename _Tp1, typename _Deleter, typename _Alloc>
- shared_ptr(_Tp1* __p, _Deleter __d, const _Alloc& __a)
- : __shared_ptr<_Tp>(__p, __d, __a) { }
+ shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
+ : __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
/**
* @brief Construct a %shared_ptr that owns a null pointer
@@ -176,8 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* The last owner will call __d(__p)
*/
template<typename _Deleter, typename _Alloc>
- shared_ptr(nullptr_t __p, _Deleter __d, const _Alloc& __a)
- : __shared_ptr<_Tp>(__p, __d, __a) { }
+ shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
+ : __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
// Aliasing constructor
@@ -305,13 +306,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
private:
// This constructor is non-standard, it is used by allocate_shared.
template<typename _Alloc, typename... _Args>
- shared_ptr(_Sp_make_shared_tag __tag, _Alloc __a, _Args&&... __args)
+ shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
+ _Args&&... __args)
: __shared_ptr<_Tp>(__tag, __a, std::forward<_Args>(__args)...)
{ }
template<typename _Tp1, typename _Alloc, typename... _Args>
friend shared_ptr<_Tp1>
- allocate_shared(_Alloc __a, _Args&&... __args);
+ allocate_shared(const _Alloc& __a, _Args&&... __args);
};
// 20.8.13.2.7 shared_ptr comparisons
@@ -521,9 +523,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/
template<typename _Tp, typename _Alloc, typename... _Args>
inline shared_ptr<_Tp>
- allocate_shared(_Alloc __a, _Args&&... __args)
+ allocate_shared(const _Alloc& __a, _Args&&... __args)
{
- return shared_ptr<_Tp>(_Sp_make_shared_tag(), std::forward<_Alloc>(__a),
+ return shared_ptr<_Tp>(_Sp_make_shared_tag(), __a,
std::forward<_Args>(__args)...);
}
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 7e7dd43..da18147 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -331,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
_Deleter _M_del; // copy constructor must not throw
_My_Deleter(_Deleter __d, const _Alloc& __a)
- : _My_alloc_type(__a), _M_del(__d) { }
+ : _My_alloc_type(__a), _M_del(__d) { }
};
protected:
@@ -504,7 +504,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _Tp, typename _Alloc, typename... _Args>
- __shared_count(_Sp_make_shared_tag, _Tp*, _Alloc __a, _Args&&... __args)
+ __shared_count(_Sp_make_shared_tag, _Tp*, const _Alloc& __a,
+ _Args&&... __args)
: _M_pi(0)
{
typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
@@ -774,8 +775,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _Tp1, typename _Deleter, typename _Alloc>
- __shared_ptr(_Tp1* __p, _Deleter __d, const _Alloc& __a)
- : _M_ptr(__p), _M_refcount(__p, __d, __a)
+ __shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
+ : _M_ptr(__p), _M_refcount(__p, __d, std::move(__a))
{
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
// TODO requires _Deleter CopyConstructible and __d(__p) well-formed
@@ -788,8 +789,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ }
template<typename _Deleter, typename _Alloc>
- __shared_ptr(nullptr_t __p, _Deleter __d, const _Alloc& __a)
- : _M_ptr(0), _M_refcount(__p, __d, __a)
+ __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
+ : _M_ptr(0), _M_refcount(__p, __d, std::move(__a))
{ }
template<typename _Tp1>
@@ -924,8 +925,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp1, typename _Deleter, typename _Alloc>
void
- reset(_Tp1* __p, _Deleter __d, const _Alloc& __a)
- { __shared_ptr(__p, __d, __a).swap(*this); }
+ reset(_Tp1* __p, _Deleter __d, _Alloc __a)
+ { __shared_ptr(__p, __d, std::move(__a)).swap(*this); }
// Allow class instantiation when _Tp is [cv-qual] void.
typename std::add_lvalue_reference<_Tp>::type
@@ -978,7 +979,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
protected:
// This constructor is non-standard, it is used by allocate_shared.
template<typename _Alloc, typename... _Args>
- __shared_ptr(_Sp_make_shared_tag __tag, _Alloc __a, _Args&&... __args)
+ __shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
+ _Args&&... __args)
: _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
std::forward<_Args>(__args)...)
{
@@ -1001,7 +1003,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
};
template<typename _Alloc, typename... _Args>
- __shared_ptr(_Sp_make_shared_tag __tag, _Alloc __a, _Args&&... __args)
+ __shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
+ _Args&&... __args)
: _M_ptr(), _M_refcount()
{
typedef typename _Alloc::template rebind<_Tp>::other _Alloc2;
@@ -1025,7 +1028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp1, _Lock_policy _Lp1, typename _Alloc,
typename... _Args>
friend __shared_ptr<_Tp1, _Lp1>
- __allocate_shared(_Alloc __a, _Args&&... __args);
+ __allocate_shared(const _Alloc& __a, _Args&&... __args);
private:
void*
@@ -1350,10 +1353,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp, _Lock_policy _Lp, typename _Alloc, typename... _Args>
inline __shared_ptr<_Tp, _Lp>
- __allocate_shared(_Alloc __a, _Args&&... __args)
+ __allocate_shared(const _Alloc& __a, _Args&&... __args)
{
- return __shared_ptr<_Tp, _Lp>(_Sp_make_shared_tag(),
- std::forward<_Alloc>(__a), std::forward<_Args>(__args)...);
+ return __shared_ptr<_Tp, _Lp>(_Sp_make_shared_tag(), __a,
+ std::forward<_Args>(__args)...);
}
template<typename _Tp, _Lock_policy _Lp, typename... _Args>
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc
index f30fd35..538126f 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc
@@ -32,9 +32,9 @@ void test01()
{
X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 764 }
+ // { dg-error "incomplete" "" { target *-*-* } 765 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 856 }
+ // { dg-error "incomplete" "" { target *-*-* } 857 }
}
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
index 044a725..c511751 100644
--- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc
@@ -41,8 +41,8 @@ main()
return 0;
}
-// { dg-warning "note" "" { target *-*-* } 350 }
-// { dg-warning "note" "" { target *-*-* } 1082 }
+// { dg-warning "note" "" { target *-*-* } 352 }
+// { dg-warning "note" "" { target *-*-* } 1085 }
// { dg-warning "note" "" { target *-*-* } 465 }
// { dg-warning "note" "" { target *-*-* } 585 }
// { dg-warning "note" "" { target *-*-* } 1027 }