aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodolfo Lima <rodolfo@rodsoft.org>2010-03-19 13:32:05 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-03-19 13:32:05 +0000
commit28de604e8cfe6d00c8e57b98f4a19bf7cf259aa3 (patch)
treeb4f81593ecde1371504930456b5f7ca5884c0007
parent8a0b1aa4c117e064a0d9e3f92e7c3e9f56d43a8a (diff)
downloadgcc-28de604e8cfe6d00c8e57b98f4a19bf7cf259aa3.zip
gcc-28de604e8cfe6d00c8e57b98f4a19bf7cf259aa3.tar.gz
gcc-28de604e8cfe6d00c8e57b98f4a19bf7cf259aa3.tar.bz2
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
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h3
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h8
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc90
4 files changed, 102 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9dec9f9..388b3cc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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.
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index b204699..5e19600 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -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>
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 9d36faf..1999f36 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -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*>)
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc
new file mode 100644
index 0000000..db17665
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc
@@ -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;
+}