This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
[default.allocator]
# 20 Memory management library [[mem]](./#mem)
## 20.2 Memory [[memory]](memory#default.allocator)
### 20.2.10 The default allocator [default.allocator]
#### [20.2.10.1](#general) General [[default.allocator.general]](default.allocator.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1956)
All specializations of the default allocator meet the
allocator completeness requirements ([[allocator.requirements.completeness]](allocator.requirements.completeness "16.4.4.6.2Allocator completeness requirements"))[.](#general-1.sentence-1)
[🔗](#lib:allocator)
namespace std {template<class T> class allocator {public:using value_type = T; using size_type = size_t; using difference_type = ptrdiff_t; using propagate_on_container_move_assignment = true_type; constexpr allocator() noexcept; constexpr allocator(const allocator&) noexcept; template<class U> constexpr allocator(const allocator<U>&) noexcept; constexpr ~allocator(); constexpr allocator& operator=(const allocator&) = default; constexpr T* allocate(size_t n); constexpr allocation_result<T*> allocate_at_least(size_t n); constexpr void deallocate(T* p, size_t n); };}
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1988)
allocator_traits<allocator<T>>::is_always_equal::value is true for any T[.](#general-2.sentence-1)
#### [20.2.10.2](#allocator.members) Members [[allocator.members]](allocator.members)
[1](#allocator.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1994)
Except for the destructor, member functions of the default allocator shall not introduce
data races ([[intro.multithread]](intro.multithread "6.10.2Multi-threaded executions and data races")) as a result of concurrent calls to those member
functions from different threads[.](#allocator.members-1.sentence-1)
Calls to these functions that allocate or deallocate a
particular unit of storage shall occur in a single total order, and each such
deallocation call shall happen before the next allocation (if any) in this order[.](#allocator.members-1.sentence-2)
[🔗](#lib:allocate,allocator)
`constexpr T* allocate(size_t n);
`
[2](#allocator.members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2007)
*Mandates*: T is not an incomplete type ([[basic.types.general]](basic.types.general#term.incomplete.type "6.9.1General"))[.](#allocator.members-2.sentence-1)
[3](#allocator.members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2011)
*Returns*: A pointer to the initial element of an array of n T[.](#allocator.members-3.sentence-1)
[4](#allocator.members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2015)
*Throws*: bad_array_new_length ifnumeric_limits<size_t>::max() / sizeof(T) < n, orbad_alloc if the storage cannot be obtained[.](#allocator.members-4.sentence-1)
[5](#allocator.members-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2021)
*Remarks*: The storage for the array
is obtained by calling ::operator new ([[new.delete]](new.delete "17.6.3Storage allocation and deallocation")),
but it is unspecified when or how often this
function is called[.](#allocator.members-5.sentence-1)
This function starts the lifetime of the array object,
but not that of any of the array elements[.](#allocator.members-5.sentence-2)
[🔗](#lib:allocate_at_least,allocator)
`constexpr allocation_result<T*> allocate_at_least(size_t n);
`
[6](#allocator.members-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2037)
*Mandates*: T is not an incomplete type ([[basic.types.general]](basic.types.general#term.incomplete.type "6.9.1General"))[.](#allocator.members-6.sentence-1)
[7](#allocator.members-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2041)
*Returns*: allocation_result<T*>{ptr, count},
where ptr is a pointer to
the initial element of an array of count T andcount ≥ n[.](#allocator.members-7.sentence-1)
[8](#allocator.members-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2048)
*Throws*: bad_array_new_length if numeric_limits<size_t>::max() / sizeof(T) < n,
or bad_alloc if the storage cannot be obtained[.](#allocator.members-8.sentence-1)
[9](#allocator.members-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2054)
*Remarks*: The storage for the array is obtained by calling ::operator new,
but it is unspecified when or how often this function is called[.](#allocator.members-9.sentence-1)
This function starts the lifetime of the array object,
but not that of any of the array elements[.](#allocator.members-9.sentence-2)
[🔗](#lib:deallocate,allocator)
`constexpr void deallocate(T* p, size_t n);
`
[10](#allocator.members-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2068)
*Preconditions*:
- [(10.1)](#allocator.members-10.1)
If p is memory that was obtained by a call to allocate_at_least,
let ret be the value returned andreq be the value passed as the first argument to that call[.](#allocator.members-10.1.sentence-1)
p is equal to ret.ptr andn is a value such that req ≤ n ≤ ret.count[.](#allocator.members-10.1.sentence-2)
- [(10.2)](#allocator.members-10.2)
Otherwise, p is a pointer value obtained from allocate[.](#allocator.members-10.2.sentence-1)
n equals the value passed as the first argument
to the invocation of allocate which returned p[.](#allocator.members-10.2.sentence-2)
[11](#allocator.members-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2083)
*Effects*: Deallocates the storage referenced by p[.](#allocator.members-11.sentence-1)
[12](#allocator.members-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2087)
*Remarks*: Uses::operator delete ([[new.delete]](new.delete "17.6.3Storage allocation and deallocation")),
but it is unspecified
when this function is called[.](#allocator.members-12.sentence-1)
#### [20.2.10.3](#allocator.globals) Operators [[allocator.globals]](allocator.globals)
[🔗](#lib:operator==,allocator)
`template<class T, class U>
constexpr bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
`
[1](#allocator.globals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2104)
*Returns*: true[.](#allocator.globals-1.sentence-1)

View File

@@ -0,0 +1,26 @@
[default.allocator.general]
# 20 Memory management library [[mem]](./#mem)
## 20.2 Memory [[memory]](memory#default.allocator.general)
### 20.2.10 The default allocator [[default.allocator]](default.allocator#general)
#### 20.2.10.1 General [default.allocator.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1956)
All specializations of the default allocator meet the
allocator completeness requirements ([[allocator.requirements.completeness]](allocator.requirements.completeness "16.4.4.6.2Allocator completeness requirements"))[.](#1.sentence-1)
[🔗](#lib:allocator)
namespace std {template<class T> class allocator {public:using value_type = T; using size_type = size_t; using difference_type = ptrdiff_t; using propagate_on_container_move_assignment = true_type; constexpr allocator() noexcept; constexpr allocator(const allocator&) noexcept; template<class U> constexpr allocator(const allocator<U>&) noexcept; constexpr ~allocator(); constexpr allocator& operator=(const allocator&) = default; constexpr T* allocate(size_t n); constexpr allocation_result<T*> allocate_at_least(size_t n); constexpr void deallocate(T* p, size_t n); };}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1988)
allocator_traits<allocator<T>>::is_always_equal::value is true for any T[.](#2.sentence-1)

View File

@@ -0,0 +1,24 @@
[default.sentinel]
# 24 Iterators library [[iterators]](./#iterators)
## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#default.sentinel)
### 24.5.6 Default sentinel [default.sentinel]
[🔗](#lib:default_sentinel_t)
`namespace std {
struct default_sentinel_t { };
}
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L5867)
Class default_sentinel_t is an empty type used to denote the end of a
range[.](#1.sentence-1)
It can be used together with iterator types that know the bound
of their range (e.g., counted_iterator ([[counted.iterator]](counted.iterator "24.5.7.1Class template counted_­iterator")))[.](#1.sentence-2)