From: Paolo Carlini Date: Mon, 6 Dec 2010 18:37:00 +0000 (+0000) Subject: shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter, const _Alloc&), [...]): Take... X-Git-Tag: releases/gcc-4.6.0~2109 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=403b89a8748380041c49f82d1ad7dee67a4e4255;p=thirdparty%2Fgcc.git shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter, const _Alloc&), [...]): Take the allocator by value, per N3225. 2010-12-06 Paolo Carlini * 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d9cdfb38e278..410743ec6b76 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2010-12-06 Paolo Carlini + + * 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 * 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 0e6f7a6d0b34..6dc9c9ffa459 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 - 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 - 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 - 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 - 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 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 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 7e7dd4395b07..da18147db5e3 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 - __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 - __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 - __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 @@ -924,8 +925,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template 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 - __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 - __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 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 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 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 f30fd35c1824..538126f694e9 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 p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 764 } + // { dg-error "incomplete" "" { target *-*-* } 765 } std::shared_ptr 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 044a7259e186..c511751f343b 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 }