2009-02-21 01:45:21 +01:00
|
|
|
// shared_ptr and weak_ptr implementation -*- C++ -*-
|
2005-03-24 19:32:18 +01:00
|
|
|
|
2011-01-31 21:46:43 +01:00
|
|
|
// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
2005-03-24 19:32:18 +01:00
|
|
|
//
|
|
|
|
// 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
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2005-03-24 19:32:18 +01:00
|
|
|
// 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2005-03-24 19:32:18 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
// GCC Note: Based on files from version 1.32.0 of the Boost library.
|
|
|
|
|
2005-03-24 19:32:18 +01:00
|
|
|
// 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)
|
|
|
|
|
2008-09-05 00:33:10 +02:00
|
|
|
/** @file bits/shared_ptr.h
|
2005-03-24 19:32:18 +01:00
|
|
|
* This is an internal header file, included by other library headers.
|
2010-12-19 10:21:16 +01:00
|
|
|
* Do not attempt to use it directly. @headername{memory}
|
2005-03-24 19:32:18 +01:00
|
|
|
*/
|
|
|
|
|
2009-03-11 16:18:12 +01:00
|
|
|
#ifndef _SHARED_PTR_H
|
|
|
|
#define _SHARED_PTR_H 1
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
#include <bits/shared_ptr_base.h>
|
2007-12-15 23:28:29 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2009-02-21 01:45:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup pointer_abstractions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/// 2.2.3.7 shared_ptr I/O
|
|
|
|
template<typename _Ch, typename _Tr, typename _Tp, _Lock_policy _Lp>
|
unique_ptr.h: (unique_ptr<>:: unique_ptr(const unique_ptr<_Up...
2010-02-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/unique_ptr.h: (unique_ptr<>::
unique_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Remove, redundant,
per DR 1303.
* include/bits/shared_ptr.h (shared_ptr<>::
shared_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Likewise.
* include/bits/shared_ptr_base.h (__shared_ptr<>::
__shared_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Likewise.
* testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc:
Likewise.
From-SVN: r156807
2010-02-16 17:01:23 +01:00
|
|
|
inline std::basic_ostream<_Ch, _Tr>&
|
2009-11-06 23:15:17 +01:00
|
|
|
operator<<(std::basic_ostream<_Ch, _Tr>& __os,
|
|
|
|
const __shared_ptr<_Tp, _Lp>& __p)
|
2006-08-23 00:34:45 +02:00
|
|
|
{
|
2009-11-06 23:15:17 +01:00
|
|
|
__os << __p.get();
|
|
|
|
return __os;
|
2006-08-23 00:34:45 +02:00
|
|
|
}
|
2006-09-22 16:22:21 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/// 2.2.3.10 shared_ptr get_deleter (experimental)
|
|
|
|
template<typename _Del, typename _Tp, _Lock_policy _Lp>
|
|
|
|
inline _Del*
|
2011-05-19 00:59:17 +02:00
|
|
|
get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
|
2009-11-20 22:23:02 +01:00
|
|
|
{
|
|
|
|
#ifdef __GXX_RTTI
|
|
|
|
return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del)));
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2005-03-24 19:32:18 +01:00
|
|
|
|
2005-11-10 13:03:50 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief A smart pointer with reference-counted copy semantics.
|
|
|
|
*
|
|
|
|
* The object pointed to is deleted when the last shared_ptr pointing to
|
|
|
|
* it is destroyed or reset.
|
|
|
|
*/
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
template<typename _Tp>
|
2009-11-06 23:15:17 +01:00
|
|
|
class shared_ptr : public __shared_ptr<_Tp>
|
2006-09-22 16:22:21 +02:00
|
|
|
{
|
|
|
|
public:
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Construct an empty %shared_ptr.
|
2006-09-22 16:22:21 +02:00
|
|
|
* @post use_count()==0 && get()==0
|
|
|
|
*/
|
2011-05-19 00:59:17 +02:00
|
|
|
constexpr shared_ptr() noexcept
|
shared_ptr.h (shared_ptr<>::__shared_ptr(), [...]): Add constexpr specifier.
2010-11-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(),
shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(),
enable_shared_from_this::enable_shared_from_this()): Add constexpr
specifier.
* include/bits/shared_ptr_base.h (__shared_count::__shared_count(),
__shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(),
__shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(),
__enable_shared_from_this::__enable_shared_from_this()): Likewise.
* include/bits/unique_ptr.h (default_delete,
unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)):
Likewise.
* testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail.
* testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test
cannot work for a non-literal type like std::shared_ptr.
* testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise.
* testsuite/util/testsuite_common_types.h: Add comments.
* testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise.
* 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: r166386
2010-11-06 01:11:57 +01:00
|
|
|
: __shared_ptr<_Tp>() { }
|
2005-03-24 19:32:18 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Construct a %shared_ptr that owns the pointer @a __p.
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
* @param __p A pointer that is convertible to element_type*.
|
|
|
|
* @post use_count() == 1 && get() == __p
|
|
|
|
* @throw std::bad_alloc, in which case @c delete @a __p is called.
|
2006-09-22 16:22:21 +02:00
|
|
|
*/
|
|
|
|
template<typename _Tp1>
|
shared_ptr.h (shared_ptr<>::__shared_ptr(), [...]): Add constexpr specifier.
2010-11-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(),
shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(),
enable_shared_from_this::enable_shared_from_this()): Add constexpr
specifier.
* include/bits/shared_ptr_base.h (__shared_count::__shared_count(),
__shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(),
__shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(),
__enable_shared_from_this::__enable_shared_from_this()): Likewise.
* include/bits/unique_ptr.h (default_delete,
unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)):
Likewise.
* testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail.
* testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test
cannot work for a non-literal type like std::shared_ptr.
* testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise.
* testsuite/util/testsuite_common_types.h: Add comments.
* testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise.
* 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: r166386
2010-11-06 01:11:57 +01:00
|
|
|
explicit shared_ptr(_Tp1* __p)
|
|
|
|
: __shared_ptr<_Tp>(__p) { }
|
2005-03-24 19:32:18 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Construct a %shared_ptr that owns the pointer @a __p
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
* and the deleter @a __d.
|
|
|
|
* @param __p A pointer.
|
|
|
|
* @param __d A deleter.
|
|
|
|
* @post use_count() == 1 && get() == __p
|
|
|
|
* @throw std::bad_alloc, in which case @a __d(__p) is called.
|
2009-11-06 23:15:17 +01:00
|
|
|
*
|
|
|
|
* Requirements: _Deleter's copy constructor and destructor must
|
|
|
|
* not throw
|
|
|
|
*
|
|
|
|
* __shared_ptr will release __p by calling __d(__p)
|
2006-09-22 16:22:21 +02:00
|
|
|
*/
|
unique_ptr.h: (unique_ptr<>:: unique_ptr(const unique_ptr<_Up...
2010-02-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/unique_ptr.h: (unique_ptr<>::
unique_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Remove, redundant,
per DR 1303.
* include/bits/shared_ptr.h (shared_ptr<>::
shared_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Likewise.
* include/bits/shared_ptr_base.h (__shared_ptr<>::
__shared_ptr(const unique_ptr<_Up, _Up_Deleter>&),
operator=(const unique_ptr<_Up, _Up_Deleter>&)): Likewise.
* testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc:
Likewise.
From-SVN: r156807
2010-02-16 17:01:23 +01:00
|
|
|
template<typename _Tp1, typename _Deleter>
|
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
2010-12-06 19:37:00 +01:00
|
|
|
shared_ptr(_Tp1* __p, _Deleter __d)
|
|
|
|
: __shared_ptr<_Tp>(__p, __d) { }
|
2009-11-06 23:15:17 +01:00
|
|
|
|
2010-06-05 19:43:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct a %shared_ptr that owns a null pointer
|
|
|
|
* and the deleter @a __d.
|
|
|
|
* @param __p A null pointer constant.
|
|
|
|
* @param __d A deleter.
|
|
|
|
* @post use_count() == 1 && get() == __p
|
|
|
|
* @throw std::bad_alloc, in which case @a __d(__p) is called.
|
|
|
|
*
|
|
|
|
* Requirements: _Deleter's copy constructor and destructor must
|
|
|
|
* not throw
|
|
|
|
*
|
|
|
|
* The last owner will call __d(__p)
|
|
|
|
*/
|
|
|
|
template<typename _Deleter>
|
|
|
|
shared_ptr(nullptr_t __p, _Deleter __d)
|
|
|
|
: __shared_ptr<_Tp>(__p, __d) { }
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Construct a %shared_ptr that owns the pointer @a __p
|
2007-12-15 23:28:29 +01:00
|
|
|
* and the deleter @a __d.
|
|
|
|
* @param __p A pointer.
|
|
|
|
* @param __d A deleter.
|
|
|
|
* @param __a An allocator.
|
|
|
|
* @post use_count() == 1 && get() == __p
|
|
|
|
* @throw std::bad_alloc, in which case @a __d(__p) is called.
|
2009-11-06 23:15:17 +01:00
|
|
|
*
|
|
|
|
* Requirements: _Deleter's copy constructor and destructor must
|
|
|
|
* not throw _Alloc's copy constructor and destructor must not
|
|
|
|
* throw.
|
|
|
|
*
|
|
|
|
* __shared_ptr will release __p by calling __d(__p)
|
2007-12-15 23:28:29 +01:00
|
|
|
*/
|
|
|
|
template<typename _Tp1, typename _Deleter, typename _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
2010-12-06 19:37:00 +01:00
|
|
|
shared_ptr(_Tp1* __p, _Deleter __d, _Alloc __a)
|
|
|
|
: __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
|
2009-11-06 23:15:17 +01:00
|
|
|
|
2010-06-05 19:43:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct a %shared_ptr that owns a null pointer
|
|
|
|
* and the deleter @a __d.
|
|
|
|
* @param __p A null pointer constant.
|
|
|
|
* @param __d A deleter.
|
|
|
|
* @param __a An allocator.
|
|
|
|
* @post use_count() == 1 && get() == __p
|
|
|
|
* @throw std::bad_alloc, in which case @a __d(__p) is called.
|
|
|
|
*
|
|
|
|
* Requirements: _Deleter's copy constructor and destructor must
|
|
|
|
* not throw _Alloc's copy constructor and destructor must not
|
|
|
|
* throw.
|
|
|
|
*
|
|
|
|
* The last owner will call __d(__p)
|
|
|
|
*/
|
|
|
|
template<typename _Deleter, typename _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
2010-12-06 19:37:00 +01:00
|
|
|
shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a)
|
|
|
|
: __shared_ptr<_Tp>(__p, __d, std::move(__a)) { }
|
2010-06-05 19:43:29 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
// Aliasing constructor
|
2007-12-15 23:28:29 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Constructs a %shared_ptr instance that stores @a __p
|
2007-12-15 23:28:29 +01:00
|
|
|
* and shares ownership with @a __r.
|
2009-11-06 23:15:17 +01:00
|
|
|
* @param __r A %shared_ptr.
|
2007-12-15 23:28:29 +01:00
|
|
|
* @param __p A pointer that will remain valid while @a *__r is valid.
|
|
|
|
* @post get() == __p && use_count() == __r.use_count()
|
|
|
|
*
|
|
|
|
* This can be used to construct a @c shared_ptr to a sub-object
|
|
|
|
* of an object managed by an existing @c shared_ptr.
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* shared_ptr< pair<int,int> > pii(new pair<int,int>());
|
|
|
|
* shared_ptr<int> pi(pii, &pii->first);
|
|
|
|
* assert(pii.use_count() == 2);
|
|
|
|
* @endcode
|
|
|
|
*/
|
|
|
|
template<typename _Tp1>
|
2011-05-19 00:59:17 +02:00
|
|
|
shared_ptr(const shared_ptr<_Tp1>& __r, _Tp* __p) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
: __shared_ptr<_Tp>(__r, __p) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief If @a __r is empty, constructs an empty %shared_ptr;
|
|
|
|
* otherwise construct a %shared_ptr that shares ownership
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
* with @a __r.
|
2009-11-06 23:15:17 +01:00
|
|
|
* @param __r A %shared_ptr.
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
* @post get() == __r.get() && use_count() == __r.use_count()
|
2006-09-22 16:22:21 +02:00
|
|
|
*/
|
2011-10-18 19:39:15 +02:00
|
|
|
shared_ptr(const shared_ptr&) noexcept = default;
|
2010-08-10 12:08:56 +02:00
|
|
|
template<typename _Tp1, typename = typename
|
|
|
|
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
|
2011-05-19 00:59:17 +02:00
|
|
|
shared_ptr(const shared_ptr<_Tp1>& __r) noexcept
|
2010-08-10 12:08:56 +02:00
|
|
|
: __shared_ptr<_Tp>(__r) { }
|
2006-09-22 16:22:21 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Move-constructs a %shared_ptr instance from @a __r.
|
|
|
|
* @param __r A %shared_ptr rvalue.
|
2007-12-15 23:28:29 +01:00
|
|
|
* @post *this contains the old value of @a __r, @a __r is empty.
|
|
|
|
*/
|
2011-05-19 00:59:17 +02:00
|
|
|
shared_ptr(shared_ptr&& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
: __shared_ptr<_Tp>(std::move(__r)) { }
|
2007-12-15 23:28:29 +01:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Move-constructs a %shared_ptr instance from @a __r.
|
|
|
|
* @param __r A %shared_ptr rvalue.
|
2007-12-15 23:28:29 +01:00
|
|
|
* @post *this contains the old value of @a __r, @a __r is empty.
|
|
|
|
*/
|
2010-08-10 12:08:56 +02:00
|
|
|
template<typename _Tp1, typename = typename
|
|
|
|
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
|
2011-05-19 00:59:17 +02:00
|
|
|
shared_ptr(shared_ptr<_Tp1>&& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
: __shared_ptr<_Tp>(std::move(__r)) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Constructs a %shared_ptr that shares ownership with @a __r
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
* and stores a copy of the pointer stored in @a __r.
|
|
|
|
* @param __r A weak_ptr.
|
|
|
|
* @post use_count() == __r.use_count()
|
|
|
|
* @throw bad_weak_ptr when __r.expired(),
|
2006-09-22 16:22:21 +02:00
|
|
|
* in which case the constructor has no effect.
|
|
|
|
*/
|
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
explicit shared_ptr(const weak_ptr<_Tp1>& __r)
|
2006-09-22 16:22:21 +02:00
|
|
|
: __shared_ptr<_Tp>(__r) { }
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
2011-01-31 21:46:43 +01:00
|
|
|
#if _GLIBCXX_USE_DEPRECATED
|
2006-09-22 16:22:21 +02:00
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
shared_ptr(std::auto_ptr<_Tp1>&& __r)
|
2008-09-05 00:33:10 +02:00
|
|
|
: __shared_ptr<_Tp>(std::move(__r)) { }
|
2007-10-29 22:13:23 +01:00
|
|
|
#endif
|
2006-09-22 16:22:21 +02:00
|
|
|
|
2008-09-05 00:33:10 +02:00
|
|
|
template<typename _Tp1, typename _Del>
|
2010-03-19 14:32:05 +01:00
|
|
|
shared_ptr(std::unique_ptr<_Tp1, _Del>&& __r)
|
2008-09-05 00:33:10 +02:00
|
|
|
: __shared_ptr<_Tp>(std::move(__r)) { }
|
2006-09-22 16:22:21 +02:00
|
|
|
|
2010-06-05 19:43:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Construct an empty %shared_ptr.
|
|
|
|
* @param __p A null pointer constant.
|
|
|
|
* @post use_count() == 0 && get() == nullptr
|
|
|
|
*/
|
2011-05-19 00:59:17 +02:00
|
|
|
constexpr shared_ptr(nullptr_t __p) noexcept
|
shared_ptr.h (shared_ptr<>::__shared_ptr(), [...]): Add constexpr specifier.
2010-11-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(),
shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(),
enable_shared_from_this::enable_shared_from_this()): Add constexpr
specifier.
* include/bits/shared_ptr_base.h (__shared_count::__shared_count(),
__shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(),
__shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(),
__enable_shared_from_this::__enable_shared_from_this()): Likewise.
* include/bits/unique_ptr.h (default_delete,
unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)):
Likewise.
* testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail.
* testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test
cannot work for a non-literal type like std::shared_ptr.
* testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise.
* testsuite/util/testsuite_common_types.h: Add comments.
* testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise.
* 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: r166386
2010-11-06 01:11:57 +01:00
|
|
|
: __shared_ptr<_Tp>(__p) { }
|
2010-06-05 19:43:29 +02:00
|
|
|
|
2011-10-18 19:39:15 +02:00
|
|
|
shared_ptr& operator=(const shared_ptr&) noexcept = default;
|
2006-09-22 16:22:21 +02:00
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
shared_ptr&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(const shared_ptr<_Tp1>& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{
|
2006-09-22 16:22:21 +02:00
|
|
|
this->__shared_ptr<_Tp>::operator=(__r);
|
|
|
|
return *this;
|
|
|
|
}
|
2006-08-23 00:34:45 +02:00
|
|
|
|
2011-01-31 21:46:43 +01:00
|
|
|
#if _GLIBCXX_USE_DEPRECATED
|
2006-09-22 16:22:21 +02:00
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
shared_ptr&
|
|
|
|
operator=(std::auto_ptr<_Tp1>&& __r)
|
|
|
|
{
|
2008-09-05 00:33:10 +02:00
|
|
|
this->__shared_ptr<_Tp>::operator=(std::move(__r));
|
2006-09-22 16:22:21 +02:00
|
|
|
return *this;
|
|
|
|
}
|
2007-10-29 22:13:23 +01:00
|
|
|
#endif
|
2007-12-15 23:28:29 +01:00
|
|
|
|
|
|
|
shared_ptr&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(shared_ptr&& __r) noexcept
|
2007-12-15 23:28:29 +01:00
|
|
|
{
|
2009-11-06 23:15:17 +01:00
|
|
|
this->__shared_ptr<_Tp>::operator=(std::move(__r));
|
|
|
|
return *this;
|
2007-12-15 23:28:29 +01:00
|
|
|
}
|
2009-11-06 23:15:17 +01:00
|
|
|
|
2007-12-15 23:28:29 +01:00
|
|
|
template<class _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
shared_ptr&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(shared_ptr<_Tp1>&& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{
|
|
|
|
this->__shared_ptr<_Tp>::operator=(std::move(__r));
|
|
|
|
return *this;
|
|
|
|
}
|
2007-12-15 23:28:29 +01:00
|
|
|
|
2008-09-05 00:33:10 +02:00
|
|
|
template<typename _Tp1, typename _Del>
|
2009-11-06 23:15:17 +01:00
|
|
|
shared_ptr&
|
|
|
|
operator=(std::unique_ptr<_Tp1, _Del>&& __r)
|
|
|
|
{
|
2008-09-05 00:33:10 +02:00
|
|
|
this->__shared_ptr<_Tp>::operator=(std::move(__r));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2007-12-15 23:28:29 +01:00
|
|
|
private:
|
|
|
|
// This constructor is non-standard, it is used by allocate_shared.
|
|
|
|
template<typename _Alloc, typename... _Args>
|
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
2010-12-06 19:37:00 +01:00
|
|
|
shared_ptr(_Sp_make_shared_tag __tag, const _Alloc& __a,
|
|
|
|
_Args&&... __args)
|
2009-11-06 23:15:17 +01:00
|
|
|
: __shared_ptr<_Tp>(__tag, __a, std::forward<_Args>(__args)...)
|
|
|
|
{ }
|
2007-12-15 23:28:29 +01:00
|
|
|
|
|
|
|
template<typename _Tp1, typename _Alloc, typename... _Args>
|
2009-11-06 23:15:17 +01:00
|
|
|
friend shared_ptr<_Tp1>
|
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
2010-12-06 19:37:00 +01:00
|
|
|
allocate_shared(const _Alloc& __a, _Args&&... __args);
|
2006-09-22 16:22:21 +02:00
|
|
|
};
|
2005-03-24 19:32:18 +01:00
|
|
|
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
// 20.8.13.2.7 shared_ptr comparisons
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator==(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
{ return __a.get() == __b.get(); }
|
|
|
|
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return !__a; }
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return !__a; }
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator!=(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
{ return __a.get() != __b.get(); }
|
|
|
|
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return (bool)__a; }
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return (bool)__a; }
|
re PR libstdc++/42925 ([GB 99] Not possible to compare unique_ptr with 0)
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/42925
* include/bits/unique_ptr.h (operator==(const unique_ptr<>&,
nullptr_t), operator==(nullptr_t, const unique_ptr<>&),
operator!=(const unique_ptr<>&, nullptr_t),
operator!=(nullptr_t, const unique_ptr<>&)): Add.
* include/bits/shared_ptr_base.h (operator==(const __shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const __shared_ptr<>&),
operator!=(const __shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const __shared_ptr<>&)): Likewise.
* include/bits/shared_ptr.h (operator==(const shared_ptr<>&,
nullptr_t), operator==(nullptr_t, const shared_ptr<>&),
operator!=(const shared_ptr<>&, nullptr_t),
operator!=(nullptr_t, const shared_ptr<>&)): Likewise.
* testsuite/20_util/unique_ptr/comparison/42925.cc: New.
* testsuite/20_util/shared_ptr/comparison/42925.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust
dg-error line numbers.
From-SVN: r163094
2010-08-11 10:49:47 +02:00
|
|
|
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
shared_ptr.h (operator>, [...]): Add, per DR 1401.
2011-03-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (operator>, operator<=, operator>=): Add,
per DR 1401.
(operator==, operator!=, operator<): Fix per the letter of DR 1401.
* include/bits/shared_ptr_base.h: Likewise for __shared_ptr.
* include/bits/unique_ptr.h (operator==, operator!=, operator<,
operator<=, operator>, operator>=): Fix per the letter of DR 1401.
* testsuite/20_util/shared_ptr/comparison/dr1401.cc: New.
* testsuite/20_util/unique_ptr/comparison/dr1401.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust.
From-SVN: r171293
2011-03-22 16:15:03 +01:00
|
|
|
operator<(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
|
|
|
{
|
|
|
|
typedef typename std::common_type<_Tp1*, _Tp2*>::type _CT;
|
|
|
|
return std::less<_CT>()(__a.get(), __b.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return std::less<_Tp*>()(__a.get(), nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return std::less<_Tp*>()(nullptr, __a.get()); }
|
|
|
|
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
|
|
|
operator<=(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
|
|
|
{ return !(__b < __a); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return !(nullptr < __a); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return !(__a < nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
|
|
|
operator>(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
|
|
|
{ return (__b < __a); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return std::less<_Tp*>()(nullptr, __a.get()); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return std::less<_Tp*>()(__a.get(), nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp1, typename _Tp2>
|
|
|
|
inline bool
|
|
|
|
operator>=(const shared_ptr<_Tp1>& __a,
|
|
|
|
const shared_ptr<_Tp2>& __b) noexcept
|
|
|
|
{ return !(__a < __b); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
|
|
|
|
{ return !(__a < nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline bool
|
|
|
|
operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
|
|
|
|
{ return !(nullptr < __a); }
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
|
|
|
|
template<typename _Tp>
|
2009-11-06 23:15:17 +01:00
|
|
|
struct less<shared_ptr<_Tp>> : public _Sp_less<shared_ptr<_Tp>>
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
{ };
|
|
|
|
|
|
|
|
// 20.8.13.2.9 shared_ptr specialized algorithms.
|
2008-09-05 00:33:10 +02:00
|
|
|
template<typename _Tp>
|
|
|
|
inline void
|
2011-05-19 00:59:17 +02:00
|
|
|
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
|
2008-09-05 00:33:10 +02:00
|
|
|
{ __a.swap(__b); }
|
|
|
|
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
// 20.8.13.2.10 shared_ptr casts.
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
template<typename _Tp, typename _Tp1>
|
2007-12-15 23:28:29 +01:00
|
|
|
inline shared_ptr<_Tp>
|
2011-05-19 00:59:17 +02:00
|
|
|
static_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
|
2008-09-05 00:33:10 +02:00
|
|
|
{ return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get())); }
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Tp1>
|
2007-12-15 23:28:29 +01:00
|
|
|
inline shared_ptr<_Tp>
|
2011-05-19 00:59:17 +02:00
|
|
|
const_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
|
2008-09-05 00:33:10 +02:00
|
|
|
{ return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); }
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Tp1>
|
2007-12-15 23:28:29 +01:00
|
|
|
inline shared_ptr<_Tp>
|
2011-05-19 00:59:17 +02:00
|
|
|
dynamic_pointer_cast(const shared_ptr<_Tp1>& __r) noexcept
|
2007-12-15 23:28:29 +01:00
|
|
|
{
|
|
|
|
if (_Tp* __p = dynamic_cast<_Tp*>(__r.get()))
|
2009-11-06 23:15:17 +01:00
|
|
|
return shared_ptr<_Tp>(__r, __p);
|
2007-12-15 23:28:29 +01:00
|
|
|
return shared_ptr<_Tp>();
|
|
|
|
}
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief A smart pointer with weak semantics.
|
|
|
|
*
|
2009-02-21 01:45:21 +01:00
|
|
|
* With forwarding constructors and assignment operators.
|
|
|
|
*/
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
template<typename _Tp>
|
2009-11-06 23:15:17 +01:00
|
|
|
class weak_ptr : public __weak_ptr<_Tp>
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
{
|
|
|
|
public:
|
2011-05-19 00:59:17 +02:00
|
|
|
constexpr weak_ptr() noexcept
|
shared_ptr.h (shared_ptr<>::__shared_ptr(), [...]): Add constexpr specifier.
2010-11-05 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/shared_ptr.h (shared_ptr<>::__shared_ptr(),
shared_ptr<>::shared_ptr(nullptr_t), weak_ptr<>::weak_ptr(),
enable_shared_from_this::enable_shared_from_this()): Add constexpr
specifier.
* include/bits/shared_ptr_base.h (__shared_count::__shared_count(),
__shared_count::__shared_count(), __shared_ptr<>::__shared_ptr(),
__shared_ptr<>::__shared_ptr(nullptr_t), __weak_ptr<>::__weak_ptr(),
__enable_shared_from_this::__enable_shared_from_this()): Likewise.
* include/bits/unique_ptr.h (default_delete,
unique_ptr<>::unique_ptr(), unique_ptr<>::unique_ptr(nullptr_t)):
Likewise.
* testsuite/20_util/default_delete/cons/constexpr.cc: Do not xfail.
* testsuite/20_util/shared_ptr/cons/constexpr.cc: Remove, the test
cannot work for a non-literal type like std::shared_ptr.
* testsuite/20_util/weak_ptr/cons/constexpr.cc: Likewise.
* testsuite/util/testsuite_common_types.h: Add comments.
* testsuite/20_util/unique_ptr/cons/constexpr.cc: Likewise.
* 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: r166386
2010-11-06 01:11:57 +01:00
|
|
|
: __weak_ptr<_Tp>() { }
|
2009-11-06 23:15:17 +01:00
|
|
|
|
2010-08-10 12:08:56 +02:00
|
|
|
template<typename _Tp1, typename = typename
|
|
|
|
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
|
2011-05-19 00:59:17 +02:00
|
|
|
weak_ptr(const weak_ptr<_Tp1>& __r) noexcept
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
: __weak_ptr<_Tp>(__r) { }
|
|
|
|
|
2010-08-10 12:08:56 +02:00
|
|
|
template<typename _Tp1, typename = typename
|
|
|
|
std::enable_if<std::is_convertible<_Tp1*, _Tp*>::value>::type>
|
2011-05-19 00:59:17 +02:00
|
|
|
weak_ptr(const shared_ptr<_Tp1>& __r) noexcept
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
: __weak_ptr<_Tp>(__r) { }
|
|
|
|
|
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
weak_ptr&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(const weak_ptr<_Tp1>& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
this->__weak_ptr<_Tp>::operator=(__r);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
weak_ptr&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(const shared_ptr<_Tp1>& __r) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
this->__weak_ptr<_Tp>::operator=(__r);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
shared_ptr<_Tp>
|
2011-05-19 00:59:17 +02:00
|
|
|
lock() const noexcept
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
{
|
|
|
|
#ifdef __GTHREADS
|
|
|
|
if (this->expired())
|
|
|
|
return shared_ptr<_Tp>();
|
|
|
|
|
2009-02-04 00:44:53 +01:00
|
|
|
__try
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
{
|
|
|
|
return shared_ptr<_Tp>(*this);
|
|
|
|
}
|
2009-02-04 00:44:53 +01:00
|
|
|
__catch(const bad_weak_ptr&)
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
{
|
|
|
|
return shared_ptr<_Tp>();
|
|
|
|
}
|
|
|
|
#else
|
2009-11-06 23:15:17 +01:00
|
|
|
return this->expired() ? shared_ptr<_Tp>() : shared_ptr<_Tp>(*this);
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
// 20.8.13.3.7 weak_ptr specialized algorithms.
|
|
|
|
template<typename _Tp>
|
|
|
|
inline void
|
2011-05-19 00:59:17 +02:00
|
|
|
swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
{ __a.swap(__b); }
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
|
|
|
|
/// Primary template owner_less
|
|
|
|
template<typename _Tp>
|
|
|
|
struct owner_less;
|
|
|
|
|
|
|
|
/// Partial specialization of owner_less for shared_ptr.
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
struct owner_less<shared_ptr<_Tp>>
|
|
|
|
: public _Sp_owner_less<shared_ptr<_Tp>, weak_ptr<_Tp>>
|
|
|
|
{ };
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/// Partial specialization of owner_less for weak_ptr.
|
shared_ptr.h: Update comparisons to match WP.
2008-11-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/bits/shared_ptr.h: Update comparisons to match WP.
(_Sp_counted_ptr): Make copy and assignment members deleted.
(_Sp_counted_deleter): Remove private copy and assignment members.
(__shared_count::_M_less,__weak_count::_M_less,operator<): Replace
friend operator< with overloaded _M_less member functions to allow
comparison with either shared_count or weak_count.
(__shared_ptr::_M_less,__weak_ptr::_M_less): Replace with...
(__shared_ptr::owner_before,__weak_ptr::owner_before): New overloads
for ownership-based ordering.
(operator<(__shared_ptr,__shared_ptr)): Compare stored pointers,
make non-friend.
(operator==(__shared_ptr,__shared_ptr)): Make non-friend.
(operator!=(__shared_ptr,__shared_ptr)): Likewise.
(less<__shared_ptr<>>,less<shared_ptr<>>,_Sp_less): Explicitly call
pointer specialization.
(__weak_ptr::operator<,weak_ptr::operator<=,weak_ptr::operator>,
weak_ptr::operator>=): Remove operator< and delete all comparisons.
(_Sp_owner_less,owner_less): Predicate for ownership-based ordering.
(operator<(shared_ptr,shared_ptr): Overload for derived shared_ptr.
(operator==(shared_ptr,shared_ptr): Likewise.
(operator!=(shared_ptr,shared_ptr): Likewise.
(swap(shared_ptr,shared_ptr)): Fix parameter types.
(swap(weak_ptr,weak_ptr)): Add missing overload.
* testsuite/20_util/owner_less/cmp.cc: New.
* testsuite/20_util/shared_ptr/comparison/cmp.cc: Test other ops.
* testsuite/20_util/shared_ptr/comparison/less.cc: New.
* testsuite/20_util/shared_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/observers/owner_before.cc: New.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: New.
From-SVN: r141512
2008-11-01 12:29:06 +01:00
|
|
|
template<typename _Tp>
|
|
|
|
struct owner_less<weak_ptr<_Tp>>
|
|
|
|
: public _Sp_owner_less<weak_ptr<_Tp>, shared_ptr<_Tp>>
|
|
|
|
{ };
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
2009-02-21 01:45:21 +01:00
|
|
|
* @brief Base class allowing use of member function shared_from_this.
|
|
|
|
*/
|
2006-09-22 16:22:21 +02:00
|
|
|
template<typename _Tp>
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
class enable_shared_from_this
|
2006-09-22 16:22:21 +02:00
|
|
|
{
|
|
|
|
protected:
|
2011-05-19 00:59:17 +02:00
|
|
|
constexpr enable_shared_from_this() noexcept { }
|
2009-11-06 23:15:17 +01:00
|
|
|
|
2011-05-19 00:59:17 +02:00
|
|
|
enable_shared_from_this(const enable_shared_from_this&) noexcept { }
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
|
|
|
enable_shared_from_this&
|
2011-05-19 00:59:17 +02:00
|
|
|
operator=(const enable_shared_from_this&) noexcept
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
{ return *this; }
|
|
|
|
|
|
|
|
~enable_shared_from_this() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
shared_ptr<_Tp>
|
|
|
|
shared_from_this()
|
|
|
|
{ return shared_ptr<_Tp>(this->_M_weak_this); }
|
|
|
|
|
|
|
|
shared_ptr<const _Tp>
|
|
|
|
shared_from_this() const
|
|
|
|
{ return shared_ptr<const _Tp>(this->_M_weak_this); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
void
|
2011-05-19 00:59:17 +02:00
|
|
|
_M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{ _M_weak_this._M_assign(__p, __n); }
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
|
|
|
template<typename _Tp1>
|
2009-11-06 23:15:17 +01:00
|
|
|
friend void
|
|
|
|
__enable_shared_from_this_helper(const __shared_count<>& __pn,
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
const enable_shared_from_this* __pe,
|
2011-05-19 00:59:17 +02:00
|
|
|
const _Tp1* __px) noexcept
|
2009-11-06 23:15:17 +01:00
|
|
|
{
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
if (__pe != 0)
|
|
|
|
__pe->_M_weak_assign(const_cast<_Tp1*>(__px), __pn);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutable weak_ptr<_Tp> _M_weak_this;
|
2006-09-22 16:22:21 +02:00
|
|
|
};
|
boost_shared_ptr.h (shared_ptr<>::shared_ptr(const __shared_ptr<>&), [...]): Remove.
2006-09-24 Paolo Carlini <pcarlini@suse.de>
* include/tr1/boost_shared_ptr.h (shared_ptr<>::shared_ptr(const
__shared_ptr<>&), shared_ptr(const __weak_ptr<>&),
shared_ptr(const __shared_ptr<>&, __static_cast_tag),
shared_ptr(const __shared_ptr<>&, __const_cast_tag),
shared_ptr(const __shared_ptr<>&, __dynamic_cast_tag),
weak_ptr<>::weak_ptr(const __shared_ptr<>&), weak_ptr(const
__weak_ptr<>&)): Remove.
(shared_ptr<>::shared_ptr(const shared_ptr<>&),
shared_ptr(const weak_ptr<>&), shared_ptr(const shared_ptr<>&,
__static_cast_tag), shared_ptr(const shared_ptr<>&,
__const_cast_tag), shared_ptr(const shared_ptr<>&,
__dynamic_cast_tag), static_pointer_cast(const shared_ptr<>&),
const_pointer_cast(const shared_ptr<>&), dynamic_pointer_cast(const
shared_ptr<>&), weak_ptr<>::weak_ptr(const shared_ptr<>&),
weak_ptr(const weak_ptr<>&), weak_ptr<>::lock(),
__enable_shared_from_this_helper(const __shared_count<>&, const
enable_shared_from_this<>*, const _Tp2*)): Add.
(class enable_shared_from_this): Add.
* testsuite/tr1/2_general_utilities/memory/enable_shared_from_this/
1.cc: New.
* testsuite/tr1/2_general_utilities/memory/shared_ptr/casts/1.cc:
Likewise.
* testsuite/tr1/2_general_utilities/memory/weak_ptr/lock/1.cc:
Likewise.
* include/tr1/boost_shared_ptr.h: Further formatting and
uglification fixes.
From-SVN: r117184
2006-09-24 21:42:34 +02:00
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Create an object that is owned by a shared_ptr.
|
2007-12-15 23:28:29 +01:00
|
|
|
* @param __a An allocator.
|
|
|
|
* @param __args Arguments for the @a _Tp object's constructor.
|
|
|
|
* @return A shared_ptr that owns the newly created object.
|
|
|
|
* @throw An exception thrown from @a _Alloc::allocate or from the
|
|
|
|
* constructor of @a _Tp.
|
|
|
|
*
|
|
|
|
* A copy of @a __a will be used to allocate memory for the shared_ptr
|
|
|
|
* and the new object.
|
|
|
|
*/
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
inline shared_ptr<_Tp>
|
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
2010-12-06 19:37:00 +01:00
|
|
|
allocate_shared(const _Alloc& __a, _Args&&... __args)
|
2007-12-15 23:28:29 +01:00
|
|
|
{
|
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
2010-12-06 19:37:00 +01:00
|
|
|
return shared_ptr<_Tp>(_Sp_make_shared_tag(), __a,
|
2009-11-06 23:15:17 +01:00
|
|
|
std::forward<_Args>(__args)...);
|
2007-12-15 23:28:29 +01:00
|
|
|
}
|
|
|
|
|
2009-11-06 23:15:17 +01:00
|
|
|
/**
|
|
|
|
* @brief Create an object that is owned by a shared_ptr.
|
2007-12-15 23:28:29 +01:00
|
|
|
* @param __args Arguments for the @a _Tp object's constructor.
|
|
|
|
* @return A shared_ptr that owns the newly created object.
|
|
|
|
* @throw std::bad_alloc, or an exception thrown from the
|
|
|
|
* constructor of @a _Tp.
|
|
|
|
*/
|
|
|
|
template<typename _Tp, typename... _Args>
|
|
|
|
inline shared_ptr<_Tp>
|
|
|
|
make_shared(_Args&&... __args)
|
|
|
|
{
|
|
|
|
typedef typename std::remove_const<_Tp>::type _Tp_nc;
|
2011-07-31 22:28:45 +02:00
|
|
|
return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(),
|
|
|
|
std::forward<_Args>(__args)...);
|
2007-12-15 23:28:29 +01:00
|
|
|
}
|
|
|
|
|
2010-06-11 18:20:24 +02:00
|
|
|
/// std::hash specialization for shared_ptr.
|
|
|
|
template<typename _Tp>
|
|
|
|
struct hash<shared_ptr<_Tp>>
|
2011-07-18 18:07:24 +02:00
|
|
|
: public __hash_base<size_t, shared_ptr<_Tp>>
|
2010-06-11 18:20:24 +02:00
|
|
|
{
|
|
|
|
size_t
|
hash-long-double-aux.cc: Rename to...
2011-11-18 Paolo Carlini <paolo.carlini@oracle.com>
* src/hash-long-double-aux.cc: Rename to...
* src/hash-long-double-tr1-aux.cc: ... this.
* src/compatibility-ldbl.cc: Adjust.
* src/hash_tr1.cc: Likewise.
* src/hash_c++0x.cc: Don't use src/hash-long-double-aux.cc.
* include/bits/functional_hash.h (hash<_Tp*>::operator(), specs
for integer types, hash<float>::operator(), hash<double>::operator(),
hash<long double>::operator()): Declare noexcept.
* include/debug/bitset (hash<__debug::bitset>::operator()): Likewise.
* include/debug/vector (hash<__debug::vector>::operator()): Likewise.
* include/std/system_error (hash<error_code>::operator()): Likewise.
* include/std/thread (hash<thread::id>::operator()): Likewise.
* include/std/bitset (hash<bitset>::operator()): Likewise.
* include/std/typeindex (hash<type_index>::operator()): Likewise.
* include/profile/bitset (hash<__profile::vector>::operator()):
Likewise.
* include/profile/vector (hash<__profile::vector>::operator()):
Likewise.
* include/ext/vstring.h (hash<__vstring>::operator(),
hash<__wvstring>::operator(), hash<__u16vstring>::operator(),
hash<__u32vstring>::operator()): Likewise.
* include/bits/shared_ptr.h (hash<shared_ptr>::operator()): Likewise.
* include/bits/shared_ptr_base.h (hash<__shared_ptr>::operator()):
Likewise.
* include/bits/unique_ptr.h (hash<unique_ptr>::operator()): Likewise.
* include/bits/basic_string.h (hash<string>::operator(),
hash<wstring>::operator(), hash<u16string>::operator(),
hash<u32string>::operator()): Likewise.
* include/bits/vector.tcc (hash<vector>::operator()): Likewise.
* include/bits/stl_bvector.h (hash<vector>::operator()): Likewise.
* libsupc++/typeinfo (type_info::hash_code): Use noexcept instead of
throw().
From-SVN: r181473
2011-11-18 13:37:06 +01:00
|
|
|
operator()(const shared_ptr<_Tp>& __s) const noexcept
|
2010-06-11 18:20:24 +02:00
|
|
|
{ return std::hash<_Tp*>()(__s.get()); }
|
|
|
|
};
|
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
// @} group pointer_abstractions
|
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2009-03-11 16:18:12 +01:00
|
|
|
|
|
|
|
#endif // _SHARED_PTR_H
|