aboutsummaryrefslogtreecommitdiff
path: root/lib/libcxx/include/memory
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcxx/include/memory')
-rw-r--r--lib/libcxx/include/memory179
1 files changed, 156 insertions, 23 deletions
diff --git a/lib/libcxx/include/memory b/lib/libcxx/include/memory
index fdb8943530..db59936707 100644
--- a/lib/libcxx/include/memory
+++ b/lib/libcxx/include/memory
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===-------------------------- memory ------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -181,47 +181,190 @@ template <class InputIterator, class ForwardIterator>
ForwardIterator
uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
+uninitialized_copy_result<InputIterator, OutputIterator>
+uninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
+
+template<input_range InputRange, nothrow-forward-range OutputRange>
+ requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>>
+uninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
+uninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20
+
+}
+
template <class InputIterator, class Size, class ForwardIterator>
ForwardIterator
uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>>
+uninitialized_copy_n_result<InputIterator, OutputIterator>
+uninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
+
+}
+
template <class ForwardIterator, class T>
void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T>
+ requires constructible_from<iter_value_t<ForwardIterator>, const T&>
+ForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20
+
+template <nothrow-forward-range ForwardRange, class T>
+ requires constructible_from<range_value_t<ForwardRange>, const T&>
+borrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20
+
+}
+
template <class ForwardIterator, class Size, class T>
ForwardIterator
uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, class T>
+ requires constructible_from<iter_value_t<ForwardIterator>, const T&>
+ForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
template <class T, class ...Args>
constexpr T* construct_at(T* location, Args&& ...args); // since C++20
+namespace ranges {
+ template<class T, class... Args>
+ constexpr T* construct_at(T* location, Args&&... args); // since C++20
+}
+
template <class T>
void destroy_at(T* location); // constexpr in C++20
+namespace ranges {
+ template<destructible T>
+ constexpr void destroy_at(T* location) noexcept; // since C++20
+}
+
template <class ForwardIterator>
void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20
+namespace ranges {
+ template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel>
+ requires destructible<iter_value_t<InputIterator>>
+ constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20
+ template<nothrow-input-range InputRange>
+ requires destructible<range_value_t<InputRange>>
+ constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20
+}
+
template <class ForwardIterator, class Size>
ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20
+namespace ranges {
+ template<nothrow-input-iterator InputIterator>
+ requires destructible<iter_value_t<InputIterator>>
+ constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20
+}
+
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
+uninitialized_move_result<InputIterator, OutputIterator>
+uninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20
+
+template<input_range InputRange, nothrow-forward-range OutputRange>
+ requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>>
+uninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>>
+uninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20
+
+}
+
template <class InputIterator, class Size, class ForwardIterator>
pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
+namespace ranges {
+
+template<class InputIterator, class OutputIterator>
+using uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20
+
+template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel>
+ requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>>
+uninitialized_move_n_result<InputIterator, OutputIterator>
+uninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20
+
+}
+
template <class ForwardIterator>
void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20
+
+template <nothrow-forward-range ForwardRange>
+ requires default_initializable<range_value_t<ForwardRange>>
+ borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20
+
+}
+
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
template <class ForwardIterator>
void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20
+
+template <nothrow-forward-range ForwardRange>
+ requires default_initializable<range_value_t<ForwardRange>>
+ borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20
+
+}
+
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
+namespace ranges {
+
+template <nothrow-forward-iterator ForwardIterator>
+ requires default_initializable<iter_value_t<ForwardIterator>>
+ ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20
+
+}
+
template <class Y> struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17
template<class X>
@@ -405,7 +548,8 @@ template<class T>
class shared_ptr
{
public:
- typedef T element_type;
+ typedef T element_type; // until C++17
+ typedef remove_extent_t<T> element_type; // since C++17
typedef weak_ptr<T> weak_type; // C++17
// constructors:
@@ -525,7 +669,8 @@ template<class T>
class weak_ptr
{
public:
- typedef T element_type;
+ typedef T element_type; // until C++17
+ typedef remove_extent_t<T> element_type; // since C++17
// constructors
constexpr weak_ptr() noexcept;
@@ -653,14 +798,6 @@ template <class T> struct hash<shared_ptr<T> >;
template <class T, class Alloc>
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
-// Pointer safety
-enum class pointer_safety { relaxed, preferred, strict }; // since C++11
-void declare_reachable(void *p); // since C++11
-template <class T> T *undeclare_reachable(T *p); // since C++11
-void declare_no_pointers(char *p, size_t n); // since C++11
-void undeclare_no_pointers(char *p, size_t n); // since C++11
-pointer_safety get_pointer_safety() noexcept; // since C++11
-
void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
} // std
@@ -675,9 +812,11 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#include <__memory/allocator_arg_t.h>
#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
+#include <__memory/concepts.h>
#include <__memory/construct_at.h>
-#include <__memory/pointer_safety.h>
#include <__memory/pointer_traits.h>
+#include <__memory/ranges_construct_at.h>
+#include <__memory/ranges_uninitialized_algorithms.h>
#include <__memory/raw_storage_iterator.h>
#include <__memory/shared_ptr.h>
#include <__memory/temporary_buffer.h>
@@ -706,10 +845,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
#pragma GCC system_header
#endif
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Alloc, class _Ptr>
@@ -842,9 +977,9 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t&
// --- Helper for container swap --
template <typename _Alloc>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
-#if _LIBCPP_STD_VER >= 14
+#if _LIBCPP_STD_VER > 11
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
@@ -855,13 +990,13 @@ void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
}
template <typename _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
template <typename _Alloc>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
-#if _LIBCPP_STD_VER >= 14
+#if _LIBCPP_STD_VER > 11
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
@@ -960,8 +1095,6 @@ struct __builtin_new_allocator {
_LIBCPP_END_NAMESPACE_STD
-_LIBCPP_POP_MACROS
-
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
# include <__pstl_memory>
#endif