Commit 640cbe76 by Jonathan Wakely Committed by Jonathan Wakely

re PR libstdc++/36962 ([C++0x] Add constructors / assignment operators from…

re PR libstdc++/36962 ([C++0x] Add constructors / assignment operators from unique_ptr to shared_ptr)

	PR libstdc++/36962
	* include/Makefile.am: Update headers.
	* include/Makefile.in: Regenerate.
	* include/std/memory: Update headers.
	* include/tr1/memory: Likewise.
	* include/tr1_impl/boost_shared_ptr.h: Remove, splitting into
	separate implementations for std and tr1.
	* include/bits/boost_sp_shared_count.h: Remove.
	* include/tr1/boost_sp_shared_count.h: Remove.
	* include/bits/shared_ptr.h: New. Combines boost_sp_shared_count.h
	and boost_shared_ptr.h into one file.
	(__shared_count,__shared_ptr,shared_ptr,swap): Add unique_ptr
	and rvalue-reference support as per current WP.
	* include/tr1/shared_ptr.h: New. Combines boost_sp_shared_count.h
	and boost_shared_ptr.h into one file.
	* testsuite/20_util/shared_ptr/cons/unique_ptr.cc: New.
	* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: New.
	* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref.cc: New.
	* testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc: New.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc: New.
	* testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc: New.
	* testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc: New.
	* testsuite/20_util/shared_ptr/modifiers/swap_rvalue.cc: New.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue_neg.cc: Remove.

From-SVN: r140012
parent 5299815b
2008-09-04 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/36962
* include/Makefile.am: Update headers.
* include/Makefile.in: Regenerate.
* include/std/memory: Update headers.
* include/tr1/memory: Likewise.
* include/tr1_impl/boost_shared_ptr.h: Remove, splitting into
separate implementations for std and tr1.
* include/bits/boost_sp_shared_count.h: Remove.
* include/tr1/boost_sp_shared_count.h: Remove.
* include/bits/shared_ptr.h: New. Combines boost_sp_shared_count.h
and boost_shared_ptr.h into one file.
(__shared_count,__shared_ptr,shared_ptr,swap): Add unique_ptr
and rvalue-reference support as per current WP.
* include/tr1/shared_ptr.h: New. Combines boost_sp_shared_count.h
and boost_shared_ptr.h into one file.
* testsuite/20_util/shared_ptr/cons/unique_ptr.cc: New.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: New.
* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref.cc: New.
* testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc: New.
* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc: New.
* testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc: New.
* testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc: New.
* testsuite/20_util/shared_ptr/modifiers/swap_rvalue.cc: New.
* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue_neg.cc: Remove.
2008-09-04 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/xml/manual/locale.xml: Fix typo.
2008-09-04 Paolo Carlini <paolo.carlini@oracle.com>
......
......@@ -81,7 +81,6 @@ bits_headers = \
${bits_srcdir}/basic_string.h \
${bits_srcdir}/basic_string.tcc \
${bits_srcdir}/boost_concept_check.h \
${bits_srcdir}/boost_sp_shared_count.h \
${bits_srcdir}/char_traits.h \
${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \
......@@ -111,6 +110,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/shared_ptr.h \
${bits_srcdir}/slice_array.h \
${bits_srcdir}/sstream.tcc \
${bits_srcdir}/stl_algo.h \
......@@ -522,7 +522,6 @@ tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/bessel_function.tcc \
${tr1_srcdir}/beta_function.tcc \
${tr1_srcdir}/boost_sp_shared_count.h \
${tr1_srcdir}/ccomplex \
${tr1_srcdir}/cctype \
${tr1_srcdir}/cfenv \
......@@ -562,6 +561,7 @@ tr1_headers = \
${tr1_srcdir}/random \
${tr1_srcdir}/regex \
${tr1_srcdir}/riemann_zeta.tcc \
${tr1_srcdir}/shared_ptr.h \
${tr1_srcdir}/special_function_util.h \
${tr1_srcdir}/stdarg.h \
${tr1_srcdir}/stdbool.h \
......@@ -582,7 +582,6 @@ tr1_impl_srcdir = ${glibcxx_srcdir}/include/tr1_impl
tr1_impl_builddir = ./tr1_impl
tr1_impl_headers = \
${tr1_impl_srcdir}/array \
${tr1_impl_srcdir}/boost_shared_ptr.h \
${tr1_impl_srcdir}/boost_sp_counted_base.h \
${tr1_impl_srcdir}/cctype \
${tr1_impl_srcdir}/cfenv \
......
......@@ -335,7 +335,6 @@ bits_headers = \
${bits_srcdir}/basic_string.h \
${bits_srcdir}/basic_string.tcc \
${bits_srcdir}/boost_concept_check.h \
${bits_srcdir}/boost_sp_shared_count.h \
${bits_srcdir}/char_traits.h \
${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \
......@@ -365,6 +364,7 @@ bits_headers = \
${bits_srcdir}/postypes.h \
${bits_srcdir}/stream_iterator.h \
${bits_srcdir}/streambuf_iterator.h \
${bits_srcdir}/shared_ptr.h \
${bits_srcdir}/slice_array.h \
${bits_srcdir}/sstream.tcc \
${bits_srcdir}/stl_algo.h \
......@@ -774,7 +774,6 @@ tr1_headers = \
${tr1_srcdir}/array \
${tr1_srcdir}/bessel_function.tcc \
${tr1_srcdir}/beta_function.tcc \
${tr1_srcdir}/boost_sp_shared_count.h \
${tr1_srcdir}/ccomplex \
${tr1_srcdir}/cctype \
${tr1_srcdir}/cfenv \
......@@ -814,6 +813,7 @@ tr1_headers = \
${tr1_srcdir}/random \
${tr1_srcdir}/regex \
${tr1_srcdir}/riemann_zeta.tcc \
${tr1_srcdir}/shared_ptr.h \
${tr1_srcdir}/special_function_util.h \
${tr1_srcdir}/stdarg.h \
${tr1_srcdir}/stdbool.h \
......@@ -833,7 +833,6 @@ tr1_impl_srcdir = ${glibcxx_srcdir}/include/tr1_impl
tr1_impl_builddir = ./tr1_impl
tr1_impl_headers = \
${tr1_impl_srcdir}/array \
${tr1_impl_srcdir}/boost_shared_ptr.h \
${tr1_impl_srcdir}/boost_sp_counted_base.h \
${tr1_impl_srcdir}/cctype \
${tr1_impl_srcdir}/cfenv \
......
......@@ -72,21 +72,20 @@
# include <bits/unique_ptr.h>
# include <debug/debug.h>
# include <type_traits>
# include <functional>
# if _GLIBCXX_DEPRECATED
# include <backward/auto_ptr.h>
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# include <tr1_impl/boost_sp_counted_base.h>
# include <bits/boost_sp_shared_count.h>
# include <tr1_impl/boost_shared_ptr.h>
# include <bits/shared_ptr.h>
# else
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1
# define _GLIBCXX_END_NAMESPACE_TR1
# define _GLIBCXX_TR1
# include <tr1_impl/boost_sp_counted_base.h>
# include <bits/boost_sp_shared_count.h>
# include <tr1_impl/boost_shared_ptr.h>
# include <bits/shared_ptr.h>
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
......
// <tr1/boost_sp_shared_count.h> -*- C++ -*-
// Copyright (C) 2007 Free Software Foundation, Inc.
//
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// shared_count.hpp
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
// shared_ptr.hpp
// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes.
// Copyright (C) 2001, 2002, 2003 Peter Dimov
// weak_ptr.hpp
// Copyright (C) 2001, 2002, 2003 Peter Dimov
// enable_shared_from_this.hpp
// Copyright (C) 2002 Peter Dimov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// GCC Note: based on version 1.32.0 of the Boost library.
/** @file tr1/boost_sp_shared_count.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
namespace std
{
namespace tr1
{
template<typename _Ptr, typename _Deleter, _Lock_policy _Lp>
class _Sp_counted_base_impl
: public _Sp_counted_base<_Lp>
{
public:
/**
* @brief
* @pre __d(__p) must not throw.
*/
_Sp_counted_base_impl(_Ptr __p, _Deleter __d)
: _M_ptr(__p), _M_del(__d) { }
virtual void
_M_dispose() // nothrow
{ _M_del(_M_ptr); }
virtual void*
_M_get_deleter(const std::type_info& __ti)
{ return __ti == typeid(_Deleter) ? &_M_del : 0; }
private:
_Sp_counted_base_impl(const _Sp_counted_base_impl&);
_Sp_counted_base_impl& operator=(const _Sp_counted_base_impl&);
_Ptr _M_ptr; // copy constructor must not throw
_Deleter _M_del; // copy constructor must not throw
};
template<_Lock_policy _Lp = __default_lock_policy>
class __weak_count;
template<typename _Tp>
struct _Sp_deleter
{
typedef void result_type;
typedef _Tp* argument_type;
void operator()(_Tp* __p) const { delete __p; }
};
template<_Lock_policy _Lp = __default_lock_policy>
class __shared_count
{
public:
__shared_count()
: _M_pi(0) // nothrow
{ }
template<typename _Ptr>
__shared_count(_Ptr __p) : _M_pi(0)
{
try
{
typedef typename std::tr1::remove_pointer<_Ptr>::type _Tp;
_M_pi = new _Sp_counted_base_impl<_Ptr, _Sp_deleter<_Tp>, _Lp>(
__p, _Sp_deleter<_Tp>());
}
catch(...)
{
delete __p;
__throw_exception_again;
}
}
template<typename _Ptr, typename _Deleter>
__shared_count(_Ptr __p, _Deleter __d) : _M_pi(0)
{
try
{
_M_pi = new _Sp_counted_base_impl<_Ptr, _Deleter, _Lp>(__p, __d);
}
catch(...)
{
__d(__p); // Call _Deleter on __p.
__throw_exception_again;
}
}
// Special case for auto_ptr<_Tp> to provide the strong guarantee.
template<typename _Tp>
explicit
__shared_count(std::auto_ptr<_Tp>& __r)
: _M_pi(new _Sp_counted_base_impl<_Tp*,
_Sp_deleter<_Tp>, _Lp >(__r.get(), _Sp_deleter<_Tp>()))
{ __r.release(); }
// Throw bad_weak_ptr when __r._M_get_use_count() == 0.
explicit
__shared_count(const __weak_count<_Lp>& __r);
~__shared_count() // nothrow
{
if (_M_pi != 0)
_M_pi->_M_release();
}
__shared_count(const __shared_count& __r)
: _M_pi(__r._M_pi) // nothrow
{
if (_M_pi != 0)
_M_pi->_M_add_ref_copy();
}
__shared_count&
operator=(const __shared_count& __r) // nothrow
{
_Sp_counted_base<_Lp>* __tmp = __r._M_pi;
if (__tmp != _M_pi)
{
if (__tmp != 0)
__tmp->_M_add_ref_copy();
if (_M_pi != 0)
_M_pi->_M_release();
_M_pi = __tmp;
}
return *this;
}
void
_M_swap(__shared_count& __r) // nothrow
{
_Sp_counted_base<_Lp>* __tmp = __r._M_pi;
__r._M_pi = _M_pi;
_M_pi = __tmp;
}
long
_M_get_use_count() const // nothrow
{ return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
bool
_M_unique() const // nothrow
{ return this->_M_get_use_count() == 1; }
friend inline bool
operator==(const __shared_count& __a, const __shared_count& __b)
{ return __a._M_pi == __b._M_pi; }
friend inline bool
operator<(const __shared_count& __a, const __shared_count& __b)
{ return std::less<_Sp_counted_base<_Lp>*>()(__a._M_pi, __b._M_pi); }
void*
_M_get_deleter(const std::type_info& __ti) const
{ return _M_pi ? _M_pi->_M_get_deleter(__ti) : 0; }
private:
friend class __weak_count<_Lp>;
_Sp_counted_base<_Lp>* _M_pi;
};
}
}
......@@ -55,16 +55,14 @@
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# include <tr1_impl/boost_sp_counted_base.h>
# include <tr1/boost_sp_shared_count.h>
# include <tr1_impl/boost_shared_ptr.h>
# include <tr1/shared_ptr.h>
#else
# define _GLIBCXX_INCLUDE_AS_TR1
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
# define _GLIBCXX_END_NAMESPACE_TR1 }
# define _GLIBCXX_TR1 tr1::
# include <tr1_impl/boost_sp_counted_base.h>
# include <tr1/boost_sp_shared_count.h>
# include <tr1_impl/boost_shared_ptr.h>
# include <tr1/shared_ptr.h>
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
......
// { dg-options "-std=gnu++0x -Wno-deprecated" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
std::auto_ptr<A> source() { return std::auto_ptr<A>(); }
// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign]
// Assignment from rvalue auto_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> a;
a = source();
return 0;
}
int
test02()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> a;
std::auto_ptr<A> au;
a = std::move(au);
return 0;
}
int
main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2005, 2006, 2007 Free Software Foundation
// Copyright (C) 2008 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
......@@ -19,24 +19,24 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.6.6.2 Template class shared_ptr [util.smartptr.shared]
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
std::auto_ptr<A> source() { return std::auto_ptr<A>(); }
// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign]
// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign]
// Assignment from rvalue auto_ptr
// Assignment from lvalue unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> a;
a = source(); // { dg-error "no match" }
std::unique_ptr<A> u;
a = u; // { dg-error "used here" }
return 0;
}
......@@ -47,4 +47,4 @@ main()
test01();
return 0;
}
// { dg-excess-errors "candidates are" }
// { dg-excess-errors "deleted function" }
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
std::unique_ptr<A> source() { return std::unique_ptr<A>(); }
// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign]
// Assignment from rvalue unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> a;
a = source();
return 0;
}
int
test02()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> a;
std::unique_ptr<A> u;
a = std::move(u);
return 0;
}
int
main()
{
test01();
test02();
return 0;
}
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
// Construction from unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::unique_ptr<A> up(new A);
std::shared_ptr<A> sp(std::move(up));
VERIFY( up.get() == 0 );
VERIFY( sp.get() != 0 );
VERIFY( sp.use_count() == 1 );
return 0;
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
struct D {
void operator()(A* p) const { delete p; ++count; }
static int count;
};
int D::count = 0;
// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
// Construction from unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::unique_ptr<A, D> up(new A, D());
{
std::shared_ptr<A> sp(std::move(up));
VERIFY( up.get() == 0 );
VERIFY( sp.get() != 0 );
VERIFY( sp.use_count() == 1 );
}
VERIFY( D::count == 1 );
return 0;
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
struct D {
typedef void result_type;
void operator()(A* p) { delete p; ++count; }
int count;
};
// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
// Construction from unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
D d = D();
std::unique_ptr<A, D&> up(new A, d);
{
std::shared_ptr<A> sp(std::move(up));
VERIFY( up.get() == 0 );
VERIFY( sp.get() != 0 );
VERIFY( sp.use_count() == 1 );
}
VERIFY( d.count == 1 );
return 0;
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const]
// Construction from lvalue unique_ptr
int
test01()
{
bool test __attribute__((unused)) = true;
std::unique_ptr<A> a;
std::shared_ptr<A> p(a); // { dg-error "used here" }
return 0;
}
int
main()
{
test01();
return 0;
}
// { dg-excess-errors "deleted function" }
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// 20.7.12.2 Template class shared_ptr [util.smartptr.shared]
#include <memory>
#include <testsuite_hooks.h>
struct A { };
// 20.7.12.2.4 shared_ptr modifiers [util.smartptr.shared.mod]
// swap
int
test01()
{
bool test __attribute__((unused)) = true;
std::shared_ptr<A> p(new A);
p.swap(std::shared_ptr<A>(new A));
return 0;
}
int
main()
{
test01();
return 0;
}
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