shared_ptr.h (shared_ptr(unique_ptr&&), [...]): Remove explicit specifier (as per DR 925).
2010-03-19 Rodolfo Lima <rodolfo@rodsoft.org> * include/bits/shared_ptr.h (shared_ptr(unique_ptr&&), shared_ptr(auto_ptr&&)): Remove explicit specifier (as per DR 925). * include/bits/shared_ptr_base.h: Likewise. * testsuite/20_util/shared_ptr/creation/dr925.cc: New. From-SVN: r157570
This commit is contained in:
parent
8a0b1aa4c1
commit
28de604e8c
4 changed files with 102 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
|||
2010-03-19 Rodolfo Lima <rodolfo@rodsoft.org>
|
||||
|
||||
* include/bits/shared_ptr.h (shared_ptr(unique_ptr&&),
|
||||
shared_ptr(auto_ptr&&)): Remove explicit specifier (as per DR 925).
|
||||
* include/bits/shared_ptr_base.h: Likewise.
|
||||
* testsuite/20_util/shared_ptr/creation/dr925.cc: New.
|
||||
|
||||
2010-03-19 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/bits/random.tcc: Minor formatting changes.
|
||||
|
|
|
@ -204,13 +204,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
|
||||
#if _GLIBCXX_DEPRECATED
|
||||
template<typename _Tp1>
|
||||
explicit
|
||||
shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
||||
: __shared_ptr<_Tp>(std::move(__r)) { }
|
||||
#endif
|
||||
|
||||
template<typename _Tp1, typename _Del>
|
||||
explicit shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
|
||||
shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
|
||||
: __shared_ptr<_Tp>(std::move(__r)) { }
|
||||
|
||||
template<typename _Tp1>
|
||||
|
|
|
@ -316,14 +316,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
#if _GLIBCXX_DEPRECATED
|
||||
// Special case for auto_ptr<_Tp> to provide the strong guarantee.
|
||||
template<typename _Tp>
|
||||
explicit __shared_count(std::auto_ptr<_Tp>&& __r)
|
||||
__shared_count(std::auto_ptr<_Tp>&& __r)
|
||||
: _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get()))
|
||||
{ __r.release(); }
|
||||
#endif
|
||||
|
||||
// Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee.
|
||||
template<typename _Tp, typename _Del>
|
||||
explicit __shared_count(std::unique_ptr<_Tp, _Del>&& __r)
|
||||
__shared_count(std::unique_ptr<_Tp, _Del>&& __r)
|
||||
: _M_pi(_S_create_from_up(std::move(__r)))
|
||||
{ __r.release(); }
|
||||
|
||||
|
@ -608,7 +608,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
|
||||
// If an exception is thrown this constructor has no effect.
|
||||
template<typename _Tp1, typename _Del>
|
||||
explicit __shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
|
||||
__shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
|
||||
: _M_ptr(__r.get()), _M_refcount()
|
||||
{
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
|
||||
|
@ -620,7 +620,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
#if _GLIBCXX_DEPRECATED
|
||||
// Postcondition: use_count() == 1 and __r.get() == 0
|
||||
template<typename _Tp1>
|
||||
explicit __shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
||||
__shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
||||
: _M_ptr(__r.get()), _M_refcount()
|
||||
{
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>)
|
||||
|
|
90
libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc
Normal file
90
libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc
Normal file
|
@ -0,0 +1,90 @@
|
|||
// { dg-options "-std=gnu++0x -Wno-deprecated" }
|
||||
|
||||
// Copyright (C) 2010 Free Software Foundation
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// 20.9.11.2 Template class shared_ptr [util.smartptr.shared]
|
||||
|
||||
#include <memory>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
struct A
|
||||
{
|
||||
};
|
||||
|
||||
std::unique_ptr<A>
|
||||
create_unique_ptr()
|
||||
{
|
||||
return std::unique_ptr<A>(new A());
|
||||
}
|
||||
|
||||
std::auto_ptr<A>
|
||||
create_auto_ptr()
|
||||
{
|
||||
return std::auto_ptr<A>(new A());
|
||||
}
|
||||
|
||||
void
|
||||
process(std::shared_ptr<A> a)
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
VERIFY( a.get() != 0 );
|
||||
VERIFY( a.use_count() == 1 );
|
||||
}
|
||||
|
||||
// 20.9.11.2.1 shared_ptr creation [util.smartptr.shared.const]
|
||||
|
||||
// Implicit conversion of auto_ptr to shared_ptr is allowed
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
process(create_auto_ptr());
|
||||
}
|
||||
|
||||
void
|
||||
test02()
|
||||
{
|
||||
std::auto_ptr<A> a = create_auto_ptr();
|
||||
process(std::move(a));
|
||||
}
|
||||
|
||||
// Implicit conversion of unique_ptr to shared_ptr is allowed
|
||||
|
||||
void
|
||||
test03()
|
||||
{
|
||||
process(create_unique_ptr());
|
||||
}
|
||||
|
||||
void
|
||||
test04()
|
||||
{
|
||||
std::unique_ptr<A> a = create_unique_ptr();
|
||||
process(std::move(a));
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test01();
|
||||
test02();
|
||||
test03();
|
||||
test04();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue