Commit 403b89a8 by Paolo Carlini Committed by Paolo Carlini

shared_ptr.h (shared_ptr<>::shared_ptr(_Tp1*, _Deleter, const _Alloc&), [...]):…

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
parent 1cd7d53f
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> 2010-12-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* acinclude.m4 (symvers_renaming): Also set if enable_symvers = no. * acinclude.m4 (symvers_renaming): Also set if enable_symvers = no.
......
...@@ -122,7 +122,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -122,7 +122,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* __shared_ptr will release __p by calling __d(__p) * __shared_ptr will release __p by calling __d(__p)
*/ */
template<typename _Tp1, typename _Deleter> 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 * @brief Construct a %shared_ptr that owns a null pointer
...@@ -157,8 +158,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -157,8 +158,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* __shared_ptr will release __p by calling __d(__p) * __shared_ptr will release __p by calling __d(__p)
*/ */
template<typename _Tp1, typename _Deleter, typename _Alloc> template<typename _Tp1, typename _Deleter, typename _Alloc>
shared_ptr(_Tp1* __p, _Deleter __d, const _Alloc& __a) shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
: __shared_ptr<_Tp>(__p, __d, __a) { } : __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
/** /**
* @brief Construct a %shared_ptr that owns a null pointer * @brief Construct a %shared_ptr that owns a null pointer
...@@ -176,8 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -176,8 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* The last owner will call __d(__p) * The last owner will call __d(__p)
*/ */
template<typename _Deleter, typename _Alloc> template<typename _Deleter, typename _Alloc>
shared_ptr(nullptr_t __p, _Deleter __d, const _Alloc& __a) shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
: __shared_ptr<_Tp>(__p, __d, __a) { } : __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
// Aliasing constructor // Aliasing constructor
...@@ -305,13 +306,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -305,13 +306,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
private: private:
// This constructor is non-standard, it is used by allocate_shared. // This constructor is non-standard, it is used by allocate_shared.
template<typename _Alloc, typename... _Args> 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)...) : __shared_ptr<_Tp>(__tag, __a, std::forward<_Args>(__args)...)
{ } { }
template<typename _Tp1, typename _Alloc, typename... _Args> template<typename _Tp1, typename _Alloc, typename... _Args>
friend shared_ptr<_Tp1> 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 // 20.8.13.2.7 shared_ptr comparisons
...@@ -521,9 +523,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -521,9 +523,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*/ */
template<typename _Tp, typename _Alloc, typename... _Args> template<typename _Tp, typename _Alloc, typename... _Args>
inline shared_ptr<_Tp> 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)...); std::forward<_Args>(__args)...);
} }
......
...@@ -331,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -331,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
_Deleter _M_del; // copy constructor must not throw _Deleter _M_del; // copy constructor must not throw
_My_Deleter(_Deleter __d, const _Alloc& __a) _My_Deleter(_Deleter __d, const _Alloc& __a)
: _My_alloc_type(__a), _M_del(__d) { } : _My_alloc_type(__a), _M_del(__d) { }
}; };
protected: protected:
...@@ -504,7 +504,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -504,7 +504,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
} }
template<typename _Tp, typename _Alloc, typename... _Args> 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) : _M_pi(0)
{ {
typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type; typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type;
...@@ -774,8 +775,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -774,8 +775,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
} }
template<typename _Tp1, typename _Deleter, typename _Alloc> template<typename _Tp1, typename _Deleter, typename _Alloc>
__shared_ptr(_Tp1* __p, _Deleter __d, const _Alloc& __a) __shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
: _M_ptr(__p), _M_refcount(__p, __d, __a) : _M_ptr(__p), _M_refcount(__p, __d, std::move(__a))
{ {
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
// TODO requires _Deleter CopyConstructible and __d(__p) well-formed // TODO requires _Deleter CopyConstructible and __d(__p) well-formed
...@@ -788,8 +789,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -788,8 +789,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ } { }
template<typename _Deleter, typename _Alloc> template<typename _Deleter, typename _Alloc>
__shared_ptr(nullptr_t __p, _Deleter __d, const _Alloc& __a) __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
: _M_ptr(0), _M_refcount(__p, __d, __a) : _M_ptr(0), _M_refcount(__p, __d, std::move(__a))
{ } { }
template<typename _Tp1> template<typename _Tp1>
...@@ -924,8 +925,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -924,8 +925,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp1, typename _Deleter, typename _Alloc> template<typename _Tp1, typename _Deleter, typename _Alloc>
void void
reset(_Tp1* __p, _Deleter __d, const _Alloc& __a) reset(_Tp1* __p, _Deleter __d, _Alloc __a)
{ __shared_ptr(__p, __d, __a).swap(*this); } { __shared_ptr(__p, __d, std::move(__a)).swap(*this); }
// 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
...@@ -978,7 +979,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -978,7 +979,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
protected: protected:
// This constructor is non-standard, it is used by allocate_shared. // This constructor is non-standard, it is used by allocate_shared.
template<typename _Alloc, typename... _Args> 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, : _M_ptr(), _M_refcount(__tag, (_Tp*)0, __a,
std::forward<_Args>(__args)...) std::forward<_Args>(__args)...)
{ {
...@@ -1001,7 +1003,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1001,7 +1003,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}; };
template<typename _Alloc, typename... _Args> 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() : _M_ptr(), _M_refcount()
{ {
typedef typename _Alloc::template rebind<_Tp>::other _Alloc2; typedef typename _Alloc::template rebind<_Tp>::other _Alloc2;
...@@ -1025,7 +1028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1025,7 +1028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp1, _Lock_policy _Lp1, typename _Alloc, template<typename _Tp1, _Lock_policy _Lp1, typename _Alloc,
typename... _Args> typename... _Args>
friend __shared_ptr<_Tp1, _Lp1> friend __shared_ptr<_Tp1, _Lp1>
__allocate_shared(_Alloc __a, _Args&&... __args); __allocate_shared(const _Alloc& __a, _Args&&... __args);
private: private:
void* void*
...@@ -1350,10 +1353,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1350,10 +1353,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _Tp, _Lock_policy _Lp, typename _Alloc, typename... _Args> template<typename _Tp, _Lock_policy _Lp, typename _Alloc, typename... _Args>
inline __shared_ptr<_Tp, _Lp> 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(), return __shared_ptr<_Tp, _Lp>(_Sp_make_shared_tag(), __a,
std::forward<_Alloc>(__a), std::forward<_Args>(__args)...); std::forward<_Args>(__args)...);
} }
template<typename _Tp, _Lock_policy _Lp, typename... _Args> template<typename _Tp, _Lock_policy _Lp, typename... _Args>
......
...@@ -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 *-*-* } 764 } // { dg-error "incomplete" "" { target *-*-* } 765 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" } std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 856 } // { dg-error "incomplete" "" { target *-*-* } 857 }
} }
...@@ -41,8 +41,8 @@ main() ...@@ -41,8 +41,8 @@ main()
return 0; return 0;
} }
// { dg-warning "note" "" { target *-*-* } 350 } // { dg-warning "note" "" { target *-*-* } 352 }
// { dg-warning "note" "" { target *-*-* } 1082 } // { dg-warning "note" "" { target *-*-* } 1085 }
// { dg-warning "note" "" { target *-*-* } 465 } // { dg-warning "note" "" { target *-*-* } 465 }
// { dg-warning "note" "" { target *-*-* } 585 } // { dg-warning "note" "" { target *-*-* } 585 }
// { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 1027 }
......
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