2008-06-21 18:55:17 +02:00
|
|
|
// unique_ptr implementation -*- C++ -*-
|
|
|
|
|
2017-01-01 13:07:43 +01:00
|
|
|
// Copyright (C) 2008-2017 Free Software Foundation, Inc.
|
2008-06-21 18:55:17 +02: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)
|
2008-06-21 18:55:17 +02: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/>.
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/** @file bits/unique_ptr.h
|
2008-06-21 18:55:17 +02: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}
|
2008-06-21 18:55:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UNIQUE_PTR_H
|
|
|
|
#define _UNIQUE_PTR_H 1
|
|
|
|
|
|
|
|
#include <bits/c++config.h>
|
2015-05-29 François Dumont fdumont@gcc.gnu.org>
* include/debug/debug.h (_GLIBCXX_DEBUG_ASSERT,
_GLIBCXX_DEBUG_PEDASSERT, _GLIBCXX_DEBUG_ONLY): Move definition...
* include/debug/assertions.h: ...here, new.
* include/debug/formatter.h
(_Error_formatter::_Is_iterator_value_type): New.
(_Error_formatter::_Is_instance): New.
(_Error_formatter::_Parameter): Make public and not friend anymore.
(_Error_formatter::_Parameter::__instance): New _M_kind enum entry.
(_Error_formatter::_Parameter::__iterator_value_type): New _M_kind enum
entry.
(_Error_formatter::_Parameter::_Type): New.
(_Error_formatter::_Parameter::_Instance): New, inherit from
latter.
(union _Error_formatter::_Parameter::_M_variant): Reorganize.
(_Parameter(_Iterator const&, const char*, _Is_iterator)): Make all
overloads take iterator through a const reference.
(_Parameter(const _Iterator&, const char*, _Is_iterator_value_type)):
New.
(_Parameter(const _Type&, const char*, _Is_instance)): New.
(_Error_formatter::_M_print_type): Delete.
(_Error_formatter::_M_iterator_value_type): New.
(_Error_formatter::_M_instance): New.
* include/Makefile.am: Add new above debug file.
* include/Makefile.in: Regenerate.
* include/debug/functions.h
(__check_dereferenceable(const _Safe_iterator<>&),
__valid_range(const _Safe_iterator<>&),
__is_safe_random_iterator<_Safe_iterator<>>): Move...
* include/debug/safe_iterator.h: ... here.
Replace debug.h include with assertions.h.
(__check_singular_aux): Move...
* include/debug/safe_base.h: ... here.
* include/debug/functions.h
(__check_dereferenceable(const _Safe_local_iterator<>&),
__valid_range(const _Safe_local_iterator<>&): Move...
* include/debug/safe_local_iterator.h: ...here.
* include/debug/safe_sequence.h: Replace debug.h with assertions.h.
Remove _Safe_iterator declaration.
* include/debug/safe_unordered_container.h: Replace debug.h with
assertions.h.
* include/debug/array: Replace safe_sequence.h include with
formatter.h and macros.h.
* include/debug/deque: Include functions.tcc.
* include/debug/forward_list: Likewise.
* include/debug/list: Likewise.
* include/debug/string: Likewise.
* include/debug/vector: Likewise.
* include/bits/unique_ptr.h: Replace debug.h include with new
assertions.h.
* include/bits/stl_iterator_base_funcs.h: Likewise.
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/array/tuple_interface/
tuple_element_debug_neg.cc: Likewise.
* src/c++11/debug.cc: Adapt.
From-SVN: r223877
2015-05-29 23:29:07 +02:00
|
|
|
#include <debug/assertions.h>
|
2008-06-21 18:55:17 +02:00
|
|
|
#include <type_traits>
|
|
|
|
#include <utility>
|
|
|
|
#include <tuple>
|
Split <functional> into smaller pieces
* include/Makefile.am: Add <bits/refwrap.h> and <bits/std_function.h>.
Order alphabetically.
* include/Makefile.in: Regenerate.
* include/bits/refwrap.h: New header.
(_Maybe_get_result_type,_Weak_result_type_impl, _Weak_result_type)
(_Reference_wrapper_base_impl, _Reference_wrapper_base)
(reference_wrapper, ref, cref): Move here from <functional>.
* include/bits/shared_ptr_base.h: Include <bits/refwrap.h> and
<bits/stl_function.h> instead of <functional>.
* include/bits/std_function.h: New header.
(_Maybe_unary_or_binary_function, bad_function_call)
(__is_location_invariant, _Nocopy_types, _Any_data)
(_Simple_type_wrapper, _Function_base, _Function_handler, function):
Move here from <functional>.
* include/bits/unique_ptr.h: Include <bits/stl_function.h>.
* include/std/functional: Include new headers and move components to
them.
* include/std/future: Include <bits/std_function.h> instead of
<functional>.
* include/std/mutex: Likewise.
* include/std/regex: Likewise.
* src/c++11/compatibility-thread-c++0x.cc: Include <functional>.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
* testsuite/20_util/default_delete/void_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Adjust dg-error
lines.
* testsuite/20_util/unique_ptr/cons/cv_qual_neg.cc: Likewise.
* testsuite/30_threads/packaged_task/49668.cc: Include <functional>.
From-SVN: r241410
2016-10-21 17:32:25 +02:00
|
|
|
#include <bits/stl_function.h>
|
2016-11-14 22:22:53 +01:00
|
|
|
#include <bits/functional_hash.h>
|
2008-06-21 18:55:17 +02: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
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/**
|
|
|
|
* @addtogroup pointer_abstractions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-08-03 02:27:48 +02:00
|
|
|
#if _GLIBCXX_USE_DEPRECATED
|
|
|
|
template<typename> class auto_ptr;
|
|
|
|
#endif
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Primary template of default_delete, used by unique_ptr
|
2010-11-02 03:35:28 +01:00
|
|
|
template<typename _Tp>
|
2008-06-21 18:55:17 +02:00
|
|
|
struct default_delete
|
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
|
|
|
{
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Default constructor
|
2011-05-21 23:50:39 +02:00
|
|
|
constexpr default_delete() noexcept = default;
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Converting constructor.
|
|
|
|
*
|
|
|
|
* Allows conversion from a deleter for arrays of another type, @p _Up,
|
|
|
|
* only if @p _Up* is convertible to @p _Tp*.
|
|
|
|
*/
|
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
|
|
|
template<typename _Up, typename = typename
|
2012-12-20 22:02:33 +01:00
|
|
|
enable_if<is_convertible<_Up*, _Tp*>::value>::type>
|
2011-05-21 23:50:39 +02:00
|
|
|
default_delete(const default_delete<_Up>&) noexcept { }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Calls @c delete @p __ptr
|
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
|
|
|
void
|
|
|
|
operator()(_Tp* __ptr) const
|
|
|
|
{
|
2013-10-30 20:48:52 +01:00
|
|
|
static_assert(!is_void<_Tp>::value,
|
|
|
|
"can't delete pointer to incomplete type");
|
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
|
|
|
static_assert(sizeof(_Tp)>0,
|
|
|
|
"can't delete pointer to incomplete type");
|
|
|
|
delete __ptr;
|
|
|
|
}
|
2008-06-21 18:55:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// DR 740 - omit specialization for array objects with a compile time length
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Specialization for arrays, default_delete.
|
2010-11-02 03:35:28 +01:00
|
|
|
template<typename _Tp>
|
2008-06-21 18:55:17 +02:00
|
|
|
struct default_delete<_Tp[]>
|
|
|
|
{
|
2012-12-20 22:02:33 +01:00
|
|
|
public:
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Default constructor
|
2011-05-21 23:50:39 +02:00
|
|
|
constexpr default_delete() noexcept = default;
|
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
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Converting constructor.
|
|
|
|
*
|
|
|
|
* Allows conversion from a deleter for arrays of another type, such as
|
|
|
|
* a const-qualified version of @p _Tp.
|
|
|
|
*
|
|
|
|
* Conversions from types derived from @c _Tp are not allowed because
|
|
|
|
* it is unsafe to @c delete[] an array of derived types through a
|
|
|
|
* pointer to the base type.
|
|
|
|
*/
|
2012-12-20 22:02:33 +01:00
|
|
|
template<typename _Up, typename = typename
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type>
|
2012-12-20 22:02:33 +01:00
|
|
|
default_delete(const default_delete<_Up[]>&) noexcept { }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Calls @c delete[] @p __ptr
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
template<typename _Up>
|
|
|
|
typename enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type
|
|
|
|
operator()(_Up* __ptr) const
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
static_assert(sizeof(_Tp)>0,
|
|
|
|
"can't delete pointer to incomplete type");
|
|
|
|
delete [] __ptr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
template <typename _Tp, typename _Dp>
|
|
|
|
class __uniq_ptr_impl
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2016-10-19 11:34:57 +02:00
|
|
|
template <typename _Up, typename _Ep, typename = void>
|
|
|
|
struct _Ptr
|
|
|
|
{
|
|
|
|
using type = _Up*;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename _Up, typename _Ep>
|
|
|
|
struct
|
|
|
|
_Ptr<_Up, _Ep, __void_t<typename remove_reference<_Ep>::type::pointer>>
|
|
|
|
{
|
|
|
|
using type = typename remove_reference<_Ep>::type::pointer;
|
|
|
|
};
|
2010-04-24 11:21:23 +02:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
public:
|
2017-01-04 14:21:02 +01:00
|
|
|
using _DeleterConstraint = enable_if<
|
|
|
|
__and_<__not_<is_pointer<_Dp>>,
|
|
|
|
is_default_constructible<_Dp>>::value>;
|
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
using pointer = typename _Ptr<_Tp, _Dp>::type;
|
2010-04-24 11:21:23 +02:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
__uniq_ptr_impl() = default;
|
|
|
|
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
|
2010-04-24 11:21:23 +02:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
template<typename _Del>
|
|
|
|
__uniq_ptr_impl(pointer __p, _Del&& __d)
|
|
|
|
: _M_t(__p, std::forward<_Del>(__d)) { }
|
2010-04-24 11:21:23 +02:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
pointer& _M_ptr() { return std::get<0>(_M_t); }
|
|
|
|
pointer _M_ptr() const { return std::get<0>(_M_t); }
|
|
|
|
_Dp& _M_deleter() { return std::get<1>(_M_t); }
|
|
|
|
const _Dp& _M_deleter() const { return std::get<1>(_M_t); }
|
2010-11-02 03:35:28 +01:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
private:
|
|
|
|
tuple<pointer, _Dp> _M_t;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// 20.7.1.2 unique_ptr for single objects.
|
|
|
|
template <typename _Tp, typename _Dp = default_delete<_Tp>>
|
|
|
|
class unique_ptr
|
|
|
|
{
|
2017-01-04 14:21:02 +01:00
|
|
|
template <class _Up>
|
|
|
|
using _DeleterConstraint =
|
|
|
|
typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type;
|
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
__uniq_ptr_impl<_Tp, _Dp> _M_t;
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
public:
|
|
|
|
using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer;
|
|
|
|
using element_type = _Tp;
|
|
|
|
using deleter_type = _Dp;
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
|
|
|
|
// helper template for detecting a safe conversion from another
|
|
|
|
// unique_ptr
|
|
|
|
template<typename _Up, typename _Ep>
|
|
|
|
using __safe_conversion_up = __and_<
|
|
|
|
is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>,
|
|
|
|
__not_<is_array<_Up>>,
|
|
|
|
__or_<__and_<is_reference<deleter_type>,
|
|
|
|
is_same<deleter_type, _Ep>>,
|
|
|
|
__and_<__not_<is_reference<deleter_type>>,
|
|
|
|
is_convertible<_Ep, deleter_type>>
|
|
|
|
>
|
|
|
|
>;
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Constructors.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Default constructor, creates a unique_ptr that owns nothing.
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Up>>
|
|
|
|
constexpr unique_ptr() noexcept
|
|
|
|
: _M_t()
|
|
|
|
{ }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
|
|
|
* @param __p A pointer to an object of @c element_type
|
|
|
|
*
|
|
|
|
* The deleter will be value-initialized.
|
|
|
|
*/
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Up>>
|
|
|
|
explicit
|
|
|
|
unique_ptr(pointer __p) noexcept
|
|
|
|
: _M_t(__p)
|
|
|
|
{ }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
|
|
|
* @param __p A pointer to an object of @c element_type
|
|
|
|
* @param __d A reference to a deleter.
|
|
|
|
*
|
|
|
|
* The deleter will be initialized with @p __d
|
|
|
|
*/
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr(pointer __p,
|
2012-12-20 22:02:33 +01:00
|
|
|
typename conditional<is_reference<deleter_type>::value,
|
2011-05-21 23:50:39 +02:00
|
|
|
deleter_type, const deleter_type&>::type __d) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(__p, __d) { }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
|
|
|
* @param __p A pointer to an object of @c element_type
|
|
|
|
* @param __d An rvalue reference to a deleter.
|
|
|
|
*
|
|
|
|
* The deleter will be initialized with @p std::move(__d)
|
|
|
|
*/
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr(pointer __p,
|
2012-12-20 22:02:33 +01:00
|
|
|
typename remove_reference<deleter_type>::type&& __d) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(std::move(__p), std::move(__d))
|
2010-11-02 03:35:28 +01:00
|
|
|
{ static_assert(!std::is_reference<deleter_type>::value,
|
2008-06-21 18:55:17 +02:00
|
|
|
"rvalue deleter bound to reference"); }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Creates a unique_ptr that owns nothing.
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Up>>
|
|
|
|
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
|
2010-06-05 19:43:29 +02:00
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Move constructors.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Move constructor.
|
2011-05-21 23:50:39 +02:00
|
|
|
unique_ptr(unique_ptr&& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(__u.release(), std::forward<deleter_type>(__u.get_deleter())) { }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Converting constructor from another type
|
|
|
|
*
|
|
|
|
* Requires that the pointer owned by @p __u is convertible to the
|
|
|
|
* type of pointer owned by this object, @p __u does not own an array,
|
|
|
|
* and @p __u has a compatible deleter type.
|
|
|
|
*/
|
2012-12-20 22:02:33 +01:00
|
|
|
template<typename _Up, typename _Ep, typename = _Require<
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
__safe_conversion_up<_Up, _Ep>,
|
2012-12-20 22:02:33 +01:00
|
|
|
typename conditional<is_reference<_Dp>::value,
|
|
|
|
is_same<_Ep, _Dp>,
|
|
|
|
is_convertible<_Ep, _Dp>>::type>>
|
2011-05-21 23:50:39 +02:00
|
|
|
unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
|
2011-04-17 23:46:11 +02:00
|
|
|
: _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
|
2008-06-21 18:55:17 +02:00
|
|
|
{ }
|
|
|
|
|
2011-01-31 21:46:43 +01:00
|
|
|
#if _GLIBCXX_USE_DEPRECATED
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Converting constructor from @c auto_ptr
|
2012-12-20 22:02:33 +01:00
|
|
|
template<typename _Up, typename = _Require<
|
|
|
|
is_convertible<_Up*, _Tp*>, is_same<_Dp, default_delete<_Tp>>>>
|
2012-08-03 02:27:48 +02:00
|
|
|
unique_ptr(auto_ptr<_Up>&& __u) noexcept;
|
2010-08-10 12:08:56 +02:00
|
|
|
#endif
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Destructor, invokes the deleter if the stored pointer is not null.
|
2012-08-26 02:12:40 +02:00
|
|
|
~unique_ptr() noexcept
|
|
|
|
{
|
2016-10-19 11:34:57 +02:00
|
|
|
auto& __ptr = _M_t._M_ptr();
|
2012-08-26 02:12:40 +02:00
|
|
|
if (__ptr != nullptr)
|
|
|
|
get_deleter()(__ptr);
|
|
|
|
__ptr = pointer();
|
|
|
|
}
|
2010-08-10 12:08:56 +02:00
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Assignment.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/** @brief Move assignment operator.
|
|
|
|
*
|
|
|
|
* @param __u The object to transfer ownership from.
|
|
|
|
*
|
|
|
|
* Invokes the deleter first if this object owns a pointer.
|
|
|
|
*/
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr&
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(unique_ptr&& __u) noexcept
|
2010-11-02 03:35:28 +01:00
|
|
|
{
|
|
|
|
reset(__u.release());
|
2011-04-16 02:55:43 +02:00
|
|
|
get_deleter() = std::forward<deleter_type>(__u.get_deleter());
|
2010-11-02 03:35:28 +01:00
|
|
|
return *this;
|
2008-06-21 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Assignment from another type.
|
|
|
|
*
|
|
|
|
* @param __u The object to transfer ownership from, which owns a
|
|
|
|
* convertible pointer to a non-array object.
|
|
|
|
*
|
|
|
|
* Invokes the deleter first if this object owns a pointer.
|
|
|
|
*/
|
2012-12-20 22:02:33 +01:00
|
|
|
template<typename _Up, typename _Ep>
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
typename enable_if< __and_<
|
|
|
|
__safe_conversion_up<_Up, _Ep>,
|
|
|
|
is_assignable<deleter_type&, _Ep&&>
|
|
|
|
>::value,
|
|
|
|
unique_ptr&>::type
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2010-11-02 03:35:28 +01:00
|
|
|
reset(__u.release());
|
2011-04-17 23:46:11 +02:00
|
|
|
get_deleter() = std::forward<_Ep>(__u.get_deleter());
|
2010-11-02 03:35:28 +01:00
|
|
|
return *this;
|
|
|
|
}
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Reset the %unique_ptr to empty, invoking the deleter if necessary.
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr&
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(nullptr_t) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Observers.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Dereference the stored pointer.
|
2012-12-20 22:02:33 +01:00
|
|
|
typename add_lvalue_reference<element_type>::type
|
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
|
|
|
operator*() const
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
Enable lightweight checks with _GLIBCXX_ASSERTIONS.
* doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document.
* doc/html/manual/using_macros.html: Regenerate.
* include/bits/c++config: Define _GLIBCXX_ASSERTIONS when
_GLIBCXX_DEBUG is defined. Disable std::string extern templates when
(_GLIBCXX_EXTERN_TEMPLATE, __glibcxx_assert): Depend on
_GLIBCXX_ASSERTIONS instead of _GLIBCXX_DEBUG.
* include/debug/debug.h [!_GLIBCXX_DEBUG]: Define
__glibcxx_requires_non_empty_range and __glibcxx_requires_nonempty.
* include/backward/auto_ptr.h (auto_ptr::operator*,
auto_ptr::operator->): Replace _GLIBCXX_DEBUG_ASSERT with
__glibcxx_assert.
* include/bits/basic_string.h (basic_string::operator[],
basic_string::front, basic_string::back, basic_string::pop_back):
Likewise.
* include/bits/random.h
(uniform_int_distribution::param_type::param_type,
uniform_real_distribution::param_type::param_type,
normal_distribution::param_type::param_type,
gamma_distribution::param_type::param_type,
bernoulli_distribution::param_type::param_type,
binomial_distribution::param_type::param_type,
geometric_distribution::param_type::param_type,
negative_binomial_distribution::param_type::param_type,
poisson_distribution::param_type::param_type,
exponential_distribution::param_type::param_type): Likewise.
* include/bits/regex.h (match_results::operator[],
match_results::prefix, match_results::suffix): Likewise.
* include/bits/regex.tcc (format, regex_iterator::operator++):
Likewise.
* include/bits/regex_automaton.tcc (_StateSeq::_M_clone): Likewise.
* include/bits/regex_compiler.tcc (_Compiler::_Compiler,
_Compiler::_M_insert_character_class_matcher): Likewise.
* include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise.
* include/bits/regex_scanner.tcc (_Scanner::_M_advance,
_Scanner::_M_scan_normal): Likewise.
* include/bits/shared_ptr_base.h (__shared_ptr::_M_reset,
__shared_ptr::operator*): Likewise.
* include/bits/stl_iterator_base_funcs.h (__advance): Likewise.
* include/bits/unique_ptr.h (unique_ptr::operator*,
unique_ptr::operator[]): Likewise.
* include/experimental/fs_path.h (path::path(string_type, _Type),
path::iterator::operator++, path::iterator::operator--,
path::iterator::operator*): Likewise.
* include/experimental/string_view (basic_string_view::operator[],
basic_string_view::front, basic_string_view::back,
basic_string_view::remove_prefix): Likewise.
* include/ext/random (beta_distribution::param_type::param_type,
normal_mv_distribution::param_type::param_type,
rice_distribution::param_type::param_type,
pareto_distribution::param_type::param_type,
k_distribution::param_type::param_type,
arcsine_distribution::param_type::param_type,
hoyt_distribution::param_type::param_type,
triangular_distribution::param_type::param_type,
von_mises_distribution::param_type::param_type,
hypergeometric_distribution::param_type::param_type,
logistic_distribution::param_type::param_type): Likewise.
* include/ext/vstring.h (__versa_string::operator[]): Likewise.
* include/std/complex (polar): Likewise.
* include/std/mutex [!_GTHREAD_USE_MUTEX_TIMEDLOCK]
(timed_mutex::~timed_mutex, timed_mutex::unlock,
(recursive_timed_mutex::~timed_mutex, recursive_timed_mutex::unlock):
Likewise.
* include/std/shared_mutex [!PTHREAD_RWLOCK_INITIALIZER]
(__shared_mutex_pthread::__shared_mutex_pthread,
__shared_mutex_pthread::~__shared_mutex_pthread): Likewise.
(__shared_mutex_pthread::lock, __shared_mutex_pthread::try_lock,
__shared_mutex_pthread::unlock, __shared_mutex_pthread::lock_shared,
__shared_mutex_pthread::try_lock_shared): Likewise.
(__shared_mutex_cv::~__shared_mutex_cv, __shared_mutex_cv::unlock,
__shared_mutex_cv::unlock_shared): Likewise.
(shared_timed_mutex::try_lock_until,
shared_timed_mutex::try_lock_shared_until): Likewise.
* include/std/valarray (valarray::valarray(const _Tp*, size_t),
valarray::operator=, valarray::sum, valarray::min, valarray::max,
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT, _DEFINE_BINARY_OPERATOR):
Likewise.
From-SVN: r227595
2015-09-09 19:12:47 +02:00
|
|
|
__glibcxx_assert(get() != pointer());
|
2008-06-21 18:55:17 +02:00
|
|
|
return *get();
|
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return the stored pointer.
|
2008-06-21 18:55:17 +02:00
|
|
|
pointer
|
2011-05-21 23:50:39 +02:00
|
|
|
operator->() const noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2015-09-07 19:17:23 +02:00
|
|
|
_GLIBCXX_DEBUG_PEDASSERT(get() != pointer());
|
2008-06-21 18:55:17 +02:00
|
|
|
return get();
|
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return the stored pointer.
|
2008-06-21 18:55:17 +02:00
|
|
|
pointer
|
2011-05-21 23:50:39 +02:00
|
|
|
get() const noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_ptr(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return a reference to the stored deleter.
|
2010-03-03 12:06:59 +01:00
|
|
|
deleter_type&
|
2011-05-21 23:50:39 +02:00
|
|
|
get_deleter() noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_deleter(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return a reference to the stored deleter.
|
2010-03-03 12:06:59 +01:00
|
|
|
const deleter_type&
|
2011-05-21 23:50:39 +02:00
|
|
|
get_deleter() const noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_deleter(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return @c true if the stored pointer is not null.
|
2011-05-21 23:50:39 +02:00
|
|
|
explicit operator bool() const noexcept
|
2010-03-02 01:40:28 +01:00
|
|
|
{ return get() == pointer() ? false : true; }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Modifiers.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Release ownership of any stored pointer.
|
2008-06-21 18:55:17 +02:00
|
|
|
pointer
|
2011-05-21 23:50:39 +02:00
|
|
|
release() noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
pointer __p = get();
|
2016-10-19 11:34:57 +02:00
|
|
|
_M_t._M_ptr() = pointer();
|
2008-06-21 18:55:17 +02:00
|
|
|
return __p;
|
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Replace the stored pointer.
|
|
|
|
*
|
|
|
|
* @param __p The new pointer to store.
|
|
|
|
*
|
|
|
|
* The deleter will be invoked if a pointer is already owned.
|
|
|
|
*/
|
2008-06-21 18:55:17 +02:00
|
|
|
void
|
2011-05-21 23:50:39 +02:00
|
|
|
reset(pointer __p = pointer()) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2010-03-02 01:40:28 +01:00
|
|
|
using std::swap;
|
2016-10-19 11:34:57 +02:00
|
|
|
swap(_M_t._M_ptr(), __p);
|
2010-03-02 01:40:28 +01:00
|
|
|
if (__p != pointer())
|
|
|
|
get_deleter()(__p);
|
2008-06-21 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Exchange the pointer and deleter with another object.
|
2008-06-21 18:55:17 +02:00
|
|
|
void
|
2011-05-21 23:50:39 +02:00
|
|
|
swap(unique_ptr& __u) noexcept
|
2008-09-28 17:47:45 +02:00
|
|
|
{
|
|
|
|
using std::swap;
|
2008-06-21 18:55:17 +02:00
|
|
|
swap(_M_t, __u._M_t);
|
|
|
|
}
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Disable copy from lvalue.
|
2008-09-28 17:47:45 +02:00
|
|
|
unique_ptr(const unique_ptr&) = delete;
|
|
|
|
unique_ptr& operator=(const unique_ptr&) = delete;
|
2008-06-21 18:55:17 +02:00
|
|
|
};
|
2010-11-02 03:35:28 +01:00
|
|
|
|
2012-08-10 00:45:20 +02:00
|
|
|
/// 20.7.1.3 unique_ptr for array objects with a runtime length
|
2008-06-21 18:55:17 +02:00
|
|
|
// [unique.ptr.runtime]
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// DR 740 - omit specialization for array objects with a compile time length
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
class unique_ptr<_Tp[], _Dp>
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up>
|
|
|
|
using _DeleterConstraint =
|
|
|
|
typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type;
|
|
|
|
|
2016-10-19 11:34:57 +02:00
|
|
|
__uniq_ptr_impl<_Tp, _Dp> _M_t;
|
2012-12-20 22:02:33 +01:00
|
|
|
|
|
|
|
template<typename _Up>
|
|
|
|
using __remove_cv = typename remove_cv<_Up>::type;
|
|
|
|
|
|
|
|
// like is_base_of<_Tp, _Up> but false if unqualified types are the same
|
|
|
|
template<typename _Up>
|
|
|
|
using __is_derived_Tp
|
|
|
|
= __and_< is_base_of<_Tp, _Up>,
|
|
|
|
__not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >;
|
|
|
|
|
2008-06-21 18:55:17 +02:00
|
|
|
public:
|
2016-10-19 11:34:57 +02:00
|
|
|
using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer;
|
|
|
|
using element_type = _Tp;
|
|
|
|
using deleter_type = _Dp;
|
2010-11-02 03:35:28 +01:00
|
|
|
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
// helper template for detecting a safe conversion from another
|
|
|
|
// unique_ptr
|
|
|
|
template<typename _Up, typename _Ep,
|
|
|
|
typename _Up_up = unique_ptr<_Up, _Ep>,
|
|
|
|
typename _Up_element_type = typename _Up_up::element_type>
|
|
|
|
using __safe_conversion_up = __and_<
|
|
|
|
is_array<_Up>,
|
|
|
|
is_same<pointer, element_type*>,
|
|
|
|
is_same<typename _Up_up::pointer, _Up_element_type*>,
|
|
|
|
is_convertible<_Up_element_type(*)[], element_type(*)[]>,
|
|
|
|
__or_<__and_<is_reference<deleter_type>, is_same<deleter_type, _Ep>>,
|
|
|
|
__and_<__not_<is_reference<deleter_type>>,
|
|
|
|
is_convertible<_Ep, deleter_type>>>
|
|
|
|
>;
|
|
|
|
|
|
|
|
// helper template for detecting a safe conversion from a raw pointer
|
|
|
|
template<typename _Up>
|
|
|
|
using __safe_conversion_raw = __and_<
|
|
|
|
__or_<__or_<is_same<_Up, pointer>,
|
|
|
|
is_same<_Up, nullptr_t>>,
|
|
|
|
__and_<is_pointer<_Up>,
|
|
|
|
is_same<pointer, element_type*>,
|
|
|
|
is_convertible<
|
|
|
|
typename remove_pointer<_Up>::type(*)[],
|
|
|
|
element_type(*)[]>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>;
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Constructors.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Default constructor, creates a unique_ptr that owns nothing.
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Up>>
|
|
|
|
constexpr unique_ptr() noexcept
|
|
|
|
: _M_t()
|
|
|
|
{ }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
* @param __p A pointer to an array of a type safely convertible
|
|
|
|
* to an array of @c element_type
|
2013-05-18 22:18:55 +02:00
|
|
|
*
|
|
|
|
* The deleter will be value-initialized.
|
|
|
|
*/
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
template<typename _Up,
|
2017-01-04 14:21:02 +01:00
|
|
|
typename _Vp = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Vp>,
|
|
|
|
typename = typename enable_if<
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
__safe_conversion_raw<_Up>::value, bool>::type>
|
2017-01-04 14:21:02 +01:00
|
|
|
explicit
|
|
|
|
unique_ptr(_Up __p) noexcept
|
|
|
|
: _M_t(__p)
|
|
|
|
{ }
|
2012-12-20 22:02:33 +01:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
* @param __p A pointer to an array of a type safely convertible
|
|
|
|
* to an array of @c element_type
|
2013-05-18 22:18:55 +02:00
|
|
|
* @param __d A reference to a deleter.
|
|
|
|
*
|
|
|
|
* The deleter will be initialized with @p __d
|
|
|
|
*/
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
template<typename _Up,
|
|
|
|
typename = typename enable_if<
|
|
|
|
__safe_conversion_raw<_Up>::value, bool>::type>
|
|
|
|
unique_ptr(_Up __p,
|
|
|
|
typename conditional<is_reference<deleter_type>::value,
|
|
|
|
deleter_type, const deleter_type&>::type __d) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(__p, __d) { }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** Takes ownership of a pointer.
|
|
|
|
*
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
* @param __p A pointer to an array of a type safely convertible
|
|
|
|
* to an array of @c element_type
|
2013-05-18 22:18:55 +02:00
|
|
|
* @param __d A reference to a deleter.
|
|
|
|
*
|
|
|
|
* The deleter will be initialized with @p std::move(__d)
|
|
|
|
*/
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
template<typename _Up,
|
|
|
|
typename = typename enable_if<
|
|
|
|
__safe_conversion_raw<_Up>::value, bool>::type>
|
|
|
|
unique_ptr(_Up __p, typename
|
2012-12-20 22:02:33 +01:00
|
|
|
remove_reference<deleter_type>::type&& __d) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(std::move(__p), std::move(__d))
|
2012-12-20 22:02:33 +01:00
|
|
|
{ static_assert(!is_reference<deleter_type>::value,
|
2008-06-21 18:55:17 +02:00
|
|
|
"rvalue deleter bound to reference"); }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Move constructor.
|
2011-05-21 23:50:39 +02:00
|
|
|
unique_ptr(unique_ptr&& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
: _M_t(__u.release(), std::forward<deleter_type>(__u.get_deleter())) { }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Creates a unique_ptr that owns nothing.
|
2017-01-04 14:21:02 +01:00
|
|
|
template <typename _Up = _Dp,
|
|
|
|
typename = _DeleterConstraint<_Up>>
|
|
|
|
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
|
2012-12-20 22:02:33 +01:00
|
|
|
|
|
|
|
template<typename _Up, typename _Ep,
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
typename = _Require<__safe_conversion_up<_Up, _Ep>>>
|
2011-05-21 23:50:39 +02:00
|
|
|
unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
|
2011-04-17 23:46:11 +02:00
|
|
|
: _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
|
2008-06-21 18:55:17 +02:00
|
|
|
{ }
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Destructor, invokes the deleter if the stored pointer is not null.
|
2012-08-26 02:12:40 +02:00
|
|
|
~unique_ptr()
|
|
|
|
{
|
2016-10-19 11:34:57 +02:00
|
|
|
auto& __ptr = _M_t._M_ptr();
|
2012-08-26 02:12:40 +02:00
|
|
|
if (__ptr != nullptr)
|
|
|
|
get_deleter()(__ptr);
|
|
|
|
__ptr = pointer();
|
|
|
|
}
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Assignment.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/** @brief Move assignment operator.
|
|
|
|
*
|
|
|
|
* @param __u The object to transfer ownership from.
|
|
|
|
*
|
|
|
|
* Invokes the deleter first if this object owns a pointer.
|
|
|
|
*/
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr&
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(unique_ptr&& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
reset(__u.release());
|
2011-04-16 02:55:43 +02:00
|
|
|
get_deleter() = std::forward<deleter_type>(__u.get_deleter());
|
2010-11-02 03:35:28 +01:00
|
|
|
return *this;
|
2008-06-21 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Assignment from another type.
|
|
|
|
*
|
|
|
|
* @param __u The object to transfer ownership from, which owns a
|
|
|
|
* convertible pointer to an array object.
|
|
|
|
*
|
|
|
|
* Invokes the deleter first if this object owns a pointer.
|
|
|
|
*/
|
2010-11-02 03:35:28 +01:00
|
|
|
template<typename _Up, typename _Ep>
|
2012-12-20 22:02:33 +01:00
|
|
|
typename
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
enable_if<__and_<__safe_conversion_up<_Up, _Ep>,
|
|
|
|
is_assignable<deleter_type&, _Ep&&>
|
|
|
|
>::value,
|
|
|
|
unique_ptr&>::type
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
2010-11-02 03:35:28 +01:00
|
|
|
reset(__u.release());
|
2011-04-17 23:46:11 +02:00
|
|
|
get_deleter() = std::forward<_Ep>(__u.get_deleter());
|
2010-11-02 03:35:28 +01:00
|
|
|
return *this;
|
|
|
|
}
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Reset the %unique_ptr to empty, invoking the deleter if necessary.
|
2008-06-21 18:55:17 +02:00
|
|
|
unique_ptr&
|
2011-05-21 23:50:39 +02:00
|
|
|
operator=(nullptr_t) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Observers.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Access an element of owned array.
|
2010-11-02 03:35:28 +01:00
|
|
|
typename std::add_lvalue_reference<element_type>::type
|
|
|
|
operator[](size_t __i) const
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
Enable lightweight checks with _GLIBCXX_ASSERTIONS.
* doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document.
* doc/html/manual/using_macros.html: Regenerate.
* include/bits/c++config: Define _GLIBCXX_ASSERTIONS when
_GLIBCXX_DEBUG is defined. Disable std::string extern templates when
(_GLIBCXX_EXTERN_TEMPLATE, __glibcxx_assert): Depend on
_GLIBCXX_ASSERTIONS instead of _GLIBCXX_DEBUG.
* include/debug/debug.h [!_GLIBCXX_DEBUG]: Define
__glibcxx_requires_non_empty_range and __glibcxx_requires_nonempty.
* include/backward/auto_ptr.h (auto_ptr::operator*,
auto_ptr::operator->): Replace _GLIBCXX_DEBUG_ASSERT with
__glibcxx_assert.
* include/bits/basic_string.h (basic_string::operator[],
basic_string::front, basic_string::back, basic_string::pop_back):
Likewise.
* include/bits/random.h
(uniform_int_distribution::param_type::param_type,
uniform_real_distribution::param_type::param_type,
normal_distribution::param_type::param_type,
gamma_distribution::param_type::param_type,
bernoulli_distribution::param_type::param_type,
binomial_distribution::param_type::param_type,
geometric_distribution::param_type::param_type,
negative_binomial_distribution::param_type::param_type,
poisson_distribution::param_type::param_type,
exponential_distribution::param_type::param_type): Likewise.
* include/bits/regex.h (match_results::operator[],
match_results::prefix, match_results::suffix): Likewise.
* include/bits/regex.tcc (format, regex_iterator::operator++):
Likewise.
* include/bits/regex_automaton.tcc (_StateSeq::_M_clone): Likewise.
* include/bits/regex_compiler.tcc (_Compiler::_Compiler,
_Compiler::_M_insert_character_class_matcher): Likewise.
* include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise.
* include/bits/regex_scanner.tcc (_Scanner::_M_advance,
_Scanner::_M_scan_normal): Likewise.
* include/bits/shared_ptr_base.h (__shared_ptr::_M_reset,
__shared_ptr::operator*): Likewise.
* include/bits/stl_iterator_base_funcs.h (__advance): Likewise.
* include/bits/unique_ptr.h (unique_ptr::operator*,
unique_ptr::operator[]): Likewise.
* include/experimental/fs_path.h (path::path(string_type, _Type),
path::iterator::operator++, path::iterator::operator--,
path::iterator::operator*): Likewise.
* include/experimental/string_view (basic_string_view::operator[],
basic_string_view::front, basic_string_view::back,
basic_string_view::remove_prefix): Likewise.
* include/ext/random (beta_distribution::param_type::param_type,
normal_mv_distribution::param_type::param_type,
rice_distribution::param_type::param_type,
pareto_distribution::param_type::param_type,
k_distribution::param_type::param_type,
arcsine_distribution::param_type::param_type,
hoyt_distribution::param_type::param_type,
triangular_distribution::param_type::param_type,
von_mises_distribution::param_type::param_type,
hypergeometric_distribution::param_type::param_type,
logistic_distribution::param_type::param_type): Likewise.
* include/ext/vstring.h (__versa_string::operator[]): Likewise.
* include/std/complex (polar): Likewise.
* include/std/mutex [!_GTHREAD_USE_MUTEX_TIMEDLOCK]
(timed_mutex::~timed_mutex, timed_mutex::unlock,
(recursive_timed_mutex::~timed_mutex, recursive_timed_mutex::unlock):
Likewise.
* include/std/shared_mutex [!PTHREAD_RWLOCK_INITIALIZER]
(__shared_mutex_pthread::__shared_mutex_pthread,
__shared_mutex_pthread::~__shared_mutex_pthread): Likewise.
(__shared_mutex_pthread::lock, __shared_mutex_pthread::try_lock,
__shared_mutex_pthread::unlock, __shared_mutex_pthread::lock_shared,
__shared_mutex_pthread::try_lock_shared): Likewise.
(__shared_mutex_cv::~__shared_mutex_cv, __shared_mutex_cv::unlock,
__shared_mutex_cv::unlock_shared): Likewise.
(shared_timed_mutex::try_lock_until,
shared_timed_mutex::try_lock_shared_until): Likewise.
* include/std/valarray (valarray::valarray(const _Tp*, size_t),
valarray::operator=, valarray::sum, valarray::min, valarray::max,
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT, _DEFINE_BINARY_OPERATOR):
Likewise.
From-SVN: r227595
2015-09-09 19:12:47 +02:00
|
|
|
__glibcxx_assert(get() != pointer());
|
2008-06-21 18:55:17 +02:00
|
|
|
return get()[__i];
|
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return the stored pointer.
|
2008-06-21 18:55:17 +02:00
|
|
|
pointer
|
2011-05-21 23:50:39 +02:00
|
|
|
get() const noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_ptr(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return a reference to the stored deleter.
|
2010-11-02 03:35:28 +01:00
|
|
|
deleter_type&
|
2011-05-21 23:50:39 +02:00
|
|
|
get_deleter() noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_deleter(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return a reference to the stored deleter.
|
2010-03-03 12:06:59 +01:00
|
|
|
const deleter_type&
|
2011-05-21 23:50:39 +02:00
|
|
|
get_deleter() const noexcept
|
2016-10-19 11:34:57 +02:00
|
|
|
{ return _M_t._M_deleter(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Return @c true if the stored pointer is not null.
|
2011-05-21 23:50:39 +02:00
|
|
|
explicit operator bool() const noexcept
|
2010-03-02 01:40:28 +01:00
|
|
|
{ return get() == pointer() ? false : true; }
|
2010-11-02 03:35:28 +01:00
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Modifiers.
|
2013-05-18 22:18:55 +02:00
|
|
|
|
|
|
|
/// Release ownership of any stored pointer.
|
2008-06-21 18:55:17 +02:00
|
|
|
pointer
|
2011-05-21 23:50:39 +02:00
|
|
|
release() noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
pointer __p = get();
|
2016-10-19 11:34:57 +02:00
|
|
|
_M_t._M_ptr() = pointer();
|
2008-06-21 18:55:17 +02:00
|
|
|
return __p;
|
|
|
|
}
|
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/** @brief Replace the stored pointer.
|
|
|
|
*
|
|
|
|
* @param __p The new pointer to store.
|
|
|
|
*
|
|
|
|
* The deleter will be invoked if a pointer is already owned.
|
|
|
|
*/
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
template <typename _Up,
|
|
|
|
typename = _Require<
|
|
|
|
__or_<is_same<_Up, pointer>,
|
|
|
|
__and_<is_same<pointer, element_type*>,
|
|
|
|
is_pointer<_Up>,
|
|
|
|
is_convertible<
|
|
|
|
typename remove_pointer<_Up>::type(*)[],
|
|
|
|
element_type(*)[]
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>>
|
2008-06-21 18:55:17 +02:00
|
|
|
void
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
reset(_Up __p) noexcept
|
2010-06-05 19:43:29 +02:00
|
|
|
{
|
2016-10-17 14:00:44 +02:00
|
|
|
pointer __ptr = __p;
|
2012-12-20 22:02:33 +01:00
|
|
|
using std::swap;
|
2016-10-19 11:34:57 +02:00
|
|
|
swap(_M_t._M_ptr(), __ptr);
|
2016-10-17 14:00:44 +02:00
|
|
|
if (__ptr != nullptr)
|
|
|
|
get_deleter()(__ptr);
|
2008-06-21 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118) and N4366 LWG 2228...
2015-08-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement N4089 Safe conversions in unique_ptr<T[]> (LWG 2118)
and N4366 LWG 2228: Missing SFINAE rule in unique_ptr
templated assignment
* include/bits/unique_ptr.h
(__remove_cv, __is_derived_Tp): Remove.
(default_delete::default_delete(const default_delete<_Up[]>)):
Constrain with array convertibility.
(default_delete::operator(_Up*)): Turn into a template,
constrain with array convertibility.
(__safe_conversion_up): New, single object version.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Constrain with deleter
convertibility.
(unique_ptr::operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint.
(__safe_conversion_up): Array version, renamed from __safe_conversion,
updated to implement N4089.
(__safe_conversion_raw): New.
(unique_ptr(_Up)): Turn into a template, constrain with array
convertibility.
(unique_ptr(_Up,
typename conditional<is_reference<deleter_type>::value,
deleter_type, const deleter_type&>::type)): Likewise.
(unique_ptr(_Up, typename
remove_reference<deleter_type>::type&&)): Likewise.
(unique_ptr(unique_ptr<_Up, _Ep>&&)): Likewise.
(operator=(unique_ptr<_Up, _Ep>&&)): Likewise, and add
is_assignable as a constraint (array version).
(reset(_Up)): Turn into a template, constrain with array
convertibility.
(reset(nullptr_t)): New.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/assign/48635.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/dr2228.cc: New.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Adjust.
From-SVN: r226733
2015-08-08 13:07:34 +02:00
|
|
|
void reset(nullptr_t = nullptr) noexcept
|
|
|
|
{
|
|
|
|
reset(pointer());
|
|
|
|
}
|
2008-09-28 17:47:45 +02:00
|
|
|
|
2013-05-18 22:18:55 +02:00
|
|
|
/// Exchange the pointer and deleter with another object.
|
2008-06-21 18:55:17 +02:00
|
|
|
void
|
2011-05-21 23:50:39 +02:00
|
|
|
swap(unique_ptr& __u) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{
|
|
|
|
using std::swap;
|
|
|
|
swap(_M_t, __u._M_t);
|
|
|
|
}
|
|
|
|
|
2009-02-05 02:50:18 +01:00
|
|
|
// Disable copy from lvalue.
|
2008-09-28 17:47:45 +02:00
|
|
|
unique_ptr(const unique_ptr&) = delete;
|
|
|
|
unique_ptr& operator=(const unique_ptr&) = delete;
|
2011-05-21 23:50:39 +02:00
|
|
|
};
|
2010-11-02 03:35:28 +01:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
2016-06-16 17:07:19 +02:00
|
|
|
inline
|
|
|
|
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
|
|
// Constrained free swap overload, see p0185r1
|
|
|
|
typename enable_if<__is_swappable<_Dp>::value>::type
|
|
|
|
#else
|
|
|
|
void
|
|
|
|
#endif
|
2010-08-11 09:42:02 +02:00
|
|
|
swap(unique_ptr<_Tp, _Dp>& __x,
|
2011-05-21 23:50:39 +02:00
|
|
|
unique_ptr<_Tp, _Dp>& __y) noexcept
|
2008-06-21 18:55:17 +02:00
|
|
|
{ __x.swap(__y); }
|
|
|
|
|
Implement LWG 2766,
Swapping non-swappable types and LWG 2749,
swappable traits for variants.
* include/bits/move.h (swap(_Tp&, _Tp&)): Constrain
with __is_tuple_like.
* include/bits/stl_pair.h (swap(pair<_T1, _T2>&, pair<_T1, _T2>&)):
Add a deleted overload.
* include/bits/unique_ptr.h
(swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&)): Likewise.
* include/std/array
(swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&)): Likewise.
* include/std/optional
(swap(optional<_Tp>&, optional<_Tp>&)): Likewise.
* include/std/tuple (__is_tuple_like_impl, __is_tuple_like):
Move to type_traits.
(swap(tuple<_Elements...>&, tuple<_Elements...>&)): Add a deleted
overload.
* include/std/type_traits (__is_tuple_like_impl, __is_tuple_like):
New.
(swap(_Tp&, _Tp&)): Constrain with __is_tuple_like.
* include/std/utility (__is_tuple_like_impl): Move to type_traits.
* include/std/variant
(swap(variant<_Types...>&, variant<_Types...>&)):
Add a deleted overload.
* testsuite/20_util/optional/swap/2.cc: Add tests for disabled
swaps.
* testsuite/20_util/pair/swap_cxx17.cc: New.
* testsuite/20_util/tuple/swap_cxx17.cc: Likewise.
* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
Likewise.
* testsuite/20_util/variant/compile.cc: Add tests for disabled
swaps.
* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
New.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Likewise.
From-SVN: r243120
2016-12-01 17:23:21 +01:00
|
|
|
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
typename enable_if<!__is_swappable<_Dp>::value>::type
|
|
|
|
swap(unique_ptr<_Tp, _Dp>&,
|
|
|
|
unique_ptr<_Tp, _Dp>&) = delete;
|
|
|
|
#endif
|
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator==(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
2008-06-21 18:55:17 +02:00
|
|
|
{ return __x.get() == __y.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, typename _Dp>
|
|
|
|
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 unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
|
|
|
|
{ return !__x; }
|
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, typename _Dp>
|
|
|
|
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 unique_ptr<_Tp, _Dp>& __x) noexcept
|
|
|
|
{ return !__x; }
|
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
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator!=(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
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
|
|
|
{ return __x.get() != __y.get(); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
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, typename _Dp>
|
|
|
|
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 unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
|
|
|
|
{ return (bool)__x; }
|
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, typename _Dp>
|
|
|
|
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 unique_ptr<_Tp, _Dp>& __x) noexcept
|
|
|
|
{ return (bool)__x; }
|
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
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator<(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
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
|
|
|
{
|
|
|
|
typedef typename
|
|
|
|
std::common_type<typename unique_ptr<_Tp, _Dp>::pointer,
|
|
|
|
typename unique_ptr<_Up, _Ep>::pointer>::type _CT;
|
|
|
|
return std::less<_CT>()(__x.get(), __y.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
|
|
|
|
{ return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(),
|
|
|
|
nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
|
|
|
|
{ return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr,
|
|
|
|
__x.get()); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator<=(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
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
|
|
|
{ return !(__y < __x); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
|
|
|
|
{ return !(nullptr < __x); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
|
|
|
|
{ return !(__x < nullptr); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator>(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
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
|
|
|
{ return (__y < __x); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
|
|
|
|
{ return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr,
|
|
|
|
__x.get()); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
|
|
|
|
{ return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(),
|
|
|
|
nullptr); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp,
|
|
|
|
typename _Up, typename _Ep>
|
2008-06-21 18:55:17 +02:00
|
|
|
inline bool
|
2010-08-11 09:42:02 +02:00
|
|
|
operator>=(const unique_ptr<_Tp, _Dp>& __x,
|
|
|
|
const unique_ptr<_Up, _Ep>& __y)
|
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
|
|
|
{ return !(__x < __y); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
|
|
|
|
{ return !(__x < nullptr); }
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
inline bool
|
|
|
|
operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
|
|
|
|
{ return !(nullptr < __x); }
|
2008-06-21 18:55:17 +02:00
|
|
|
|
2010-06-11 18:20:24 +02:00
|
|
|
/// std::hash specialization for unique_ptr.
|
2010-08-11 09:42:02 +02:00
|
|
|
template<typename _Tp, typename _Dp>
|
|
|
|
struct hash<unique_ptr<_Tp, _Dp>>
|
2016-11-14 22:22:53 +01:00
|
|
|
: public __hash_base<size_t, unique_ptr<_Tp, _Dp>>,
|
|
|
|
private __poison_hash<typename unique_ptr<_Tp, _Dp>::pointer>
|
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 unique_ptr<_Tp, _Dp>& __u) const noexcept
|
2010-06-11 18:20:24 +02:00
|
|
|
{
|
2022-08-11 22:09:28 +02:00
|
|
|
#if defined(__LCC__) && defined(__QNXNTO__) // _UP is a macro in QNX-libc
|
|
|
|
typedef unique_ptr<_Tp, _Dp> _Up;
|
|
|
|
return std::hash<typename _Up::pointer>()(__u.get());
|
|
|
|
#else // defined(__LCC__) && defined(__QNXNTO__)
|
2010-08-11 09:42:02 +02:00
|
|
|
typedef unique_ptr<_Tp, _Dp> _UP;
|
2010-06-11 18:20:24 +02:00
|
|
|
return std::hash<typename _UP::pointer>()(__u.get());
|
2022-08-11 22:09:28 +02:00
|
|
|
#endif // defined(__LCC__) && defined(__QNXNTO__)
|
2010-06-11 18:20:24 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-18 17:07:02 +02:00
|
|
|
#if __cplusplus > 201103L
|
2014-10-01 13:49:23 +02:00
|
|
|
|
|
|
|
#define __cpp_lib_make_unique 201304
|
|
|
|
|
2013-05-18 17:07:02 +02:00
|
|
|
template<typename _Tp>
|
|
|
|
struct _MakeUniq
|
|
|
|
{ typedef unique_ptr<_Tp> __single_object; };
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct _MakeUniq<_Tp[]>
|
|
|
|
{ typedef unique_ptr<_Tp[]> __array; };
|
|
|
|
|
|
|
|
template<typename _Tp, size_t _Bound>
|
|
|
|
struct _MakeUniq<_Tp[_Bound]>
|
|
|
|
{ struct __invalid_type { }; };
|
|
|
|
|
|
|
|
/// std::make_unique for single objects
|
|
|
|
template<typename _Tp, typename... _Args>
|
2013-05-18 22:18:55 +02:00
|
|
|
inline typename _MakeUniq<_Tp>::__single_object
|
2013-05-18 17:07:02 +02:00
|
|
|
make_unique(_Args&&... __args)
|
|
|
|
{ return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
|
|
|
|
|
|
|
|
/// std::make_unique for arrays of unknown bound
|
|
|
|
template<typename _Tp>
|
2013-05-18 22:18:55 +02:00
|
|
|
inline typename _MakeUniq<_Tp>::__array
|
2013-05-18 17:07:02 +02:00
|
|
|
make_unique(size_t __num)
|
2014-11-04 03:49:20 +01:00
|
|
|
{ return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
|
2013-05-18 17:07:02 +02:00
|
|
|
|
|
|
|
/// Disable std::make_unique for arrays of known bound
|
|
|
|
template<typename _Tp, typename... _Args>
|
2013-05-18 22:18:55 +02:00
|
|
|
inline typename _MakeUniq<_Tp>::__invalid_type
|
2013-05-18 17:07:02 +02:00
|
|
|
make_unique(_Args&&...) = delete;
|
|
|
|
#endif
|
|
|
|
|
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
|
2008-06-21 18:55:17 +02:00
|
|
|
|
|
|
|
#endif /* _UNIQUE_PTR_H */
|