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,42 @@
[indirect.array.assign]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#indirect.array.assign)
### 29.6.9 Class template indirect_array [[template.indirect.array]](template.indirect.array#indirect.array.assign)
#### 29.6.9.2 Assignment [indirect.array.assign]
[🔗](#lib:operator=,indirect_array)
`void operator=(const valarray<T>&) const;
const indirect_array& operator=(const indirect_array&) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9057)
These assignment operators have reference semantics, assigning the values
of the argument array elements to selected elements of thevalarray<T> object to which it refers[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9063)
If theindirect_array specifies an element in thevalarray<T> object to which it refers more than once, the behavior is undefined[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9071)
[*Example [1](#example-1)*:
int addr[] = {2, 3, 1, 4, 4};
valarray<size_t> indirect(addr, 5);
valarray<double> a(0., 10), b(1., 5);
a[indirect] = b; results in undefined behavior since element 4 is specified twice in the
indirection[.](#3.sentence-1)
— *end example*]

View File

@@ -0,0 +1,37 @@
[indirect.array.comp.assign]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#indirect.array.comp.assign)
### 29.6.9 Class template indirect_array [[template.indirect.array]](template.indirect.array#indirect.array.comp.assign)
#### 29.6.9.3 Compound assignment [indirect.array.comp.assign]
[🔗](#lib:operator*=,indirect_array)
`void operator*= (const valarray<T>&) const;
void operator/= (const valarray<T>&) const;
void operator%= (const valarray<T>&) const;
void operator+= (const valarray<T>&) const;
void operator-= (const valarray<T>&) const;
void operator^= (const valarray<T>&) const;
void operator&= (const valarray<T>&) const;
void operator|= (const valarray<T>&) const;
void operator<<=(const valarray<T>&) const;
void operator>>=(const valarray<T>&) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9110)
These compound assignments have reference semantics, applying the indicated
operation to the elements of the argument array and selected elements of thevalarray<T> object to which theindirect_array object refers[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9118)
If theindirect_array specifies an element in thevalarray<T> object to which it refers more than once,
the behavior is undefined[.](#2.sentence-1)

View File

@@ -0,0 +1,21 @@
[indirect.array.fill]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#indirect.array.fill)
### 29.6.9 Class template indirect_array [[template.indirect.array]](template.indirect.array#indirect.array.fill)
#### 29.6.9.4 Fill function [indirect.array.fill]
[🔗](#lib:operator=,indirect_array)
`void operator=(const T&) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9136)
This function has reference semantics, assigning the value of its argument
to the elements of thevalarray<T> object to which theindirect_array object refers[.](#1.sentence-1)

216
cppdraft/indirect/assign.md Normal file
View File

@@ -0,0 +1,216 @@
[indirect.assign]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.assign)
### 20.4.1 Class template indirect [[indirect]](indirect#assign)
#### 20.4.1.5 Assignment [indirect.assign]
[🔗](#lib:operator=,indirect)
`constexpr indirect& operator=(const indirect& other);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6358)
*Mandates*:
- [(1.1)](#1.1)
is_copy_assignable_v<T> is true, and
- [(1.2)](#1.2)
is_copy_constructible_v<T> is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6368)
*Effects*: If addressof(other) == this is true, there are no effects[.](#2.sentence-1)
Otherwise:
- [(2.1)](#2.1)
The allocator needs updating ifallocator_traits<Allocator>::propagate_on_container_copy_assignment::value is true[.](#2.1.sentence-1)
- [(2.2)](#2.2)
If other is valueless,*this becomes valueless and
the owned object in *this, if any,
is destroyed using allocator_traits<Allocator>::destroy and
then the storage is deallocated[.](#2.2.sentence-1)
- [(2.3)](#2.3)
Otherwise,
if *alloc* == other.*alloc* is true and*this is not valueless,
equivalent to **this = *other[.](#2.3.sentence-1)
- [(2.4)](#2.4)
Otherwise a new owned object is constructed in *this using allocator_traits<Allocator>::con
struct with
the owned object from other as the argument,
using either the allocator in *this or
the allocator in other if the allocator needs updating[.](#2.4.sentence-1)
- [(2.5)](#2.5)
The previously owned object in *this, if any,
is destroyed using allocator_traits<Allocator>::
destroy and
then the storage is deallocated[.](#2.5.sentence-1)
- [(2.6)](#2.6)
If the allocator needs updating,
the allocator in *this is replaced with
a copy of the allocator in other[.](#2.6.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6415)
*Returns*: A reference to *this[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6419)
*Remarks*: If any exception is thrown,
the result of the expression this->valueless_after_move() remains unchanged[.](#4.sentence-1)
If an exception is thrown during
the call to T's selected copy constructor, no effect[.](#4.sentence-2)
If an exception is thrown during the call to T's copy assignment,
the state of its owned object
is as defined by the exception safety guarantee ofT's copy assignment[.](#4.sentence-3)
[🔗](#lib:operator=,indirect_)
`constexpr indirect& operator=(indirect&& other)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
allocator_traits<Allocator>::is_always_equal::value);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6440)
*Mandates*: is_copy_constructible_t<T> is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6444)
*Effects*: If addressof(other) == this is true, there are no effects[.](#6.sentence-1)
Otherwise:
- [(6.1)](#6.1)
The allocator needs updating ifallocator_traits<Allocator>::propagate_on_container_move_assignment::value is true[.](#6.1.sentence-1)
- [(6.2)](#6.2)
If other is valueless,*this becomes valueless and
the owned object in *this, if any,
is destroyed using allocator_traits<Allocator>::destroy and
then the storage is deallocated[.](#6.2.sentence-1)
- [(6.3)](#6.3)
Otherwise,
if *alloc* == other.*alloc* is true,
swaps the owned objects in *this and other;
the owned object in other, if any,
is then destroyed using allocator_traits<Allocator>::destroy and
then the storage is deallocated[.](#6.3.sentence-1)
- [(6.4)](#6.4)
Otherwise,
constructs a new owned object with
the owned object of other as the argument as an rvalue,
using either
the allocator in *this or
the allocator in other if the allocator needs updating[.](#6.4.sentence-1)
- [(6.5)](#6.5)
The previously owned object in *this, if any,
is destroyed using allocator_traits<Allocator>::
destroy and
then the storage is deallocated[.](#6.5.sentence-1)
- [(6.6)](#6.6)
If the allocator needs updating,
the allocator in *this is replaced with
a copy of the allocator in other[.](#6.6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6493)
*Postconditions*: other is valueless[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6497)
*Returns*: A reference to *this[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6501)
*Remarks*: If any exception is thrown,
there are no effects on *this or other[.](#9.sentence-1)
[🔗](#lib:operator=,indirect__)
`template<class U = T>
constexpr indirect& operator=(U&& u);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6514)
*Constraints*:
- [(10.1)](#10.1)
is_same_v<remove_cvref_t<U>, indirect> is false,
- [(10.2)](#10.2)
is_constructible_v<T, U> is true, and
- [(10.3)](#10.3)
is_assignable_v<T&, U> is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6525)
*Effects*: If *this is valueless then
constructs an owned object of type T with std::forward<U>(u) using the allocator *alloc*[.](#11.sentence-1)
Otherwise,
equivalent to **this = std::forward<U>(u)[.](#11.sentence-2)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6533)
*Returns*: A reference to *this[.](#12.sentence-1)

View File

@@ -0,0 +1,43 @@
[indirect.comp.with.t]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.comp.with.t)
### 20.4.1 Class template indirect [[indirect]](indirect#comp.with.t)
#### 20.4.1.9 Comparison with T [indirect.comp.with.t]
[🔗](#itemdecl:1)
`template<class U>
constexpr bool operator==(const indirect& lhs, const U& rhs) noexcept(noexcept(*lhs == rhs));
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6705)
*Mandates*: The expression *lhs == rhs is well-formed and
its result is convertible to bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6710)
*Returns*: If lhs is valueless, false;
otherwise *lhs == rhs[.](#2.sentence-1)
[🔗](#itemdecl:2)
`template<class U>
constexpr synth-three-way-result<T, U>
operator<=>(const indirect& lhs, const U& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6725)
*Returns*: If lhs is valueless, strong_ordering::less;
otherwise *synth-three-way*(*lhs, rhs)[.](#3.sentence-1)

333
cppdraft/indirect/ctor.md Normal file
View File

@@ -0,0 +1,333 @@
[indirect.ctor]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.ctor)
### 20.4.1 Class template indirect [[indirect]](indirect#ctor)
#### 20.4.1.3 Constructors [indirect.ctor]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6059)
The following element applies to all functions in [indirect.ctor]:
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6063)
*Throws*: Nothing unless allocator_traits<Allocator>::allocate orallocator_traits<Allocator>::construct throws[.](#2.sentence-1)
[🔗](#lib:indirect,constructor)
`constexpr explicit indirect();
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6075)
*Constraints*: is_default_constructible_v<Allocator> is true[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6079)
*Mandates*: is_default_constructible_v<T> is true[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6083)
*Effects*: Constructs an owned object of type T with an empty argument list,
using the allocator *alloc*[.](#5.sentence-1)
[🔗](#lib:indirect,constructor_)
`constexpr explicit indirect(allocator_arg_t, const Allocator& a);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6095)
*Mandates*: is_default_constructible_v<T> is true[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6099)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#7.sentence-1)
Constructs an owned object of type T with an empty argument list,
using the allocator *alloc*[.](#7.sentence-2)
[🔗](#lib:indirect,constructor__)
`constexpr indirect(const indirect& other);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6112)
*Mandates*: is_copy_constructible_v<T> is true[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6116)
*Effects*: *alloc* is direct-non-list-initialized withallocator_traits<Allocator>::select_on_container_copy_construction(other.*alloc*)[.](#9.sentence-1)
If other is valueless, *this is valueless[.](#9.sentence-2)
Otherwise,
constructs an owned object of type T with *other,
using the allocator *alloc*[.](#9.sentence-3)
[🔗](#lib:indirect,constructor___)
`constexpr indirect(allocator_arg_t, const Allocator& a, const indirect& other);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6132)
*Mandates*: is_copy_constructible_v<T> is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6136)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#11.sentence-1)
If other is valueless, *this is valueless[.](#11.sentence-2)
Otherwise,
constructs an owned object of type T with *other,
using the allocator *alloc*[.](#11.sentence-3)
[🔗](#lib:indirect,constructor____)
`constexpr indirect(indirect&& other) noexcept;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6151)
*Effects*: *alloc* is direct-non-list-initialized fromstd::move(other.*alloc*)[.](#12.sentence-1)
If other is valueless, *this is valueless[.](#12.sentence-2)
Otherwise *this takes ownership of the owned object of other[.](#12.sentence-3)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6158)
*Postconditions*: other is valueless[.](#13.sentence-1)
[🔗](#lib:indirect,constructor_____)
`constexpr indirect(allocator_arg_t, const Allocator& a, indirect&& other)
noexcept(allocator_traits<Allocator>::is_always_equal::value);
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6170)
*Mandates*: If allocator_traits<Allocator>::is_always_equal::value is false then T is a complete type[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6175)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#15.sentence-1)
If other is valueless, *this is valueless[.](#15.sentence-2)
Otherwise,
if *alloc* == other.*alloc* is true,
constructs an object of type indirect that
takes ownership of the owned object of other[.](#15.sentence-3)
Otherwise,
constructs an owned object of type T with *std::move(other),
using the allocator *alloc*[.](#15.sentence-4)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6187)
*Postconditions*: other is valueless[.](#16.sentence-1)
[🔗](#lib:indirect,constructor______)
`template<class U = T>
constexpr explicit indirect(U&& u);
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6199)
*Constraints*:
- [(17.1)](#17.1)
is_same_v<remove_cvref_t<U>, indirect> is false,
- [(17.2)](#17.2)
is_same_v<remove_cvref_t<U>, in_place_t> is false,
- [(17.3)](#17.3)
is_constructible_v<T, U> is true, and
- [(17.4)](#17.4)
is_default_constructible_v<Allocator> is true[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6212)
*Effects*: Constructs an owned object of type T with std::forward<U>(u),
using the allocator *alloc*[.](#18.sentence-1)
[🔗](#lib:indirect,constructor_______)
`template<class U = T>
constexpr explicit indirect(allocator_arg_t, const Allocator& a, U&& u);
`
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6225)
*Constraints*:
- [(19.1)](#19.1)
is_same_v<remove_cvref_t<U>, indirect> is false,
- [(19.2)](#19.2)
is_same_v<remove_cvref_t<U>, in_place_t> is false, and
- [(19.3)](#19.3)
is_constructible_v<T, U> is true[.](#19.sentence-1)
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6236)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#20.sentence-1)
Constructs an owned object of type T withstd::forward<U>(u),
using the allocator *alloc*[.](#20.sentence-2)
[🔗](#lib:indirect,constructor________)
`template<class... Us>
constexpr explicit indirect(in_place_t, Us&&... us);
`
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6251)
*Constraints*:
- [(21.1)](#21.1)
is_constructible_v<T, Us...> is true, and
- [(21.2)](#21.2)
is_default_constructible_v<Allocator> is true[.](#21.sentence-1)
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6260)
*Effects*: Constructs an owned object of type T withstd::forward<Us>(us)...,
using the allocator *alloc*[.](#22.sentence-1)
[🔗](#lib:indirect,constructor_________)
`template<class... Us>
constexpr explicit indirect(allocator_arg_t, const Allocator& a,
in_place_t, Us&& ...us);
`
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6275)
*Constraints*: is_constructible_v<T, Us...> is true[.](#23.sentence-1)
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6279)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#24.sentence-1)
Constructs an owned object of type T withstd::forward<Us>(us)...,
using the allocator *alloc*[.](#24.sentence-2)
[🔗](#lib:indirect,constructor__________)
`template<class I, class... Us>
constexpr explicit indirect(in_place_t, initializer_list<I> ilist, Us&&... us);
`
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6294)
*Constraints*:
- [(25.1)](#25.1)
is_constructible_v<T, initializer_list<I>&, Us...> is true, and
- [(25.2)](#25.2)
is_default_constructible_v<Allocator> is true[.](#25.sentence-1)
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6303)
*Effects*: Constructs an owned object of type T with the argumentsilist, std::forward<Us>(us)...,
using the allocator *alloc*[.](#26.sentence-1)
[🔗](#lib:indirect,constructor___________)
`template<class I, class... Us>
constexpr explicit indirect(allocator_arg_t, const Allocator& a,
in_place_t, initializer_list<I> ilist, Us&&... us);
`
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6318)
*Constraints*: is_constructible_v<T, initializer_list<I>&, Us...> is true[.](#27.sentence-1)
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6322)
*Effects*: *alloc* is direct-non-list-initialized with a[.](#28.sentence-1)
Constructs an owned object of type T with the argumentsilist, std::forward<Us>(us)...,
using the allocator *alloc*[.](#28.sentence-2)

29
cppdraft/indirect/dtor.md Normal file
View File

@@ -0,0 +1,29 @@
[indirect.dtor]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.dtor)
### 20.4.1 Class template indirect [[indirect]](indirect#dtor)
#### 20.4.1.4 Destructor [indirect.dtor]
[🔗](#lib:indirect,destructor)
`constexpr ~indirect();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6338)
*Mandates*: T is a complete type[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6342)
*Effects*: If *this is not valueless,
destroys the owned object
using allocator_traits<Allocator>::destroy and
then the storage is deallocated[.](#2.sentence-1)

View File

@@ -0,0 +1,102 @@
[indirect.general]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.general)
### 20.4.1 Class template indirect [[indirect]](indirect#general)
#### 20.4.1.1 General [indirect.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5901)
An indirect object manages the lifetime of an owned object[.](#1.sentence-1)
An indirect object is[*valueless*](#def:valueless,indirect_object "20.4.1.1General[indirect.general]") if it has no owned object[.](#1.sentence-2)
An indirect object may become valueless only after it has been moved from[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5907)
In every specialization indirect<T, Allocator>,
if the type allocator_traits<Allocator>::value_type is not the same type as T,
the program is ill-formed[.](#2.sentence-1)
Every object of type indirect<T, Allocator> uses an object of type Allocator to allocate and free storage
for the owned object as needed[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5916)
Constructing an owned object with args... using the allocator a means callingallocator_traits<Allocator>::construct(a, *p*, args...) whereargs is an expression pack,a is an allocator, and*p* is a pointer obtained by
calling allocator_traits<Allocator>::allocate[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5925)
The member *alloc* is used for
any memory allocation and element construction
performed by member functions
during the lifetime of each indirect object[.](#4.sentence-1)
The allocator *alloc* may be replaced
only via assignment or swap()[.](#4.sentence-2)
Allocator replacement is performed by
copy assignment,
move assignment, or
swapping of the allocator
only if ([[container.reqmts]](container.reqmts "23.2.2.2Container requirements")):
- [(4.1)](#4.1)
allocator_traits<Allocator>::propagate_on_container_copy_assignment::value, or
- [(4.2)](#4.2)
allocator_traits<Allocator>::propagate_on_container_move_assignment::value, or
- [(4.3)](#4.3)
allocator_traits<Allocator>::propagate_on_container_swap::value
is true within the implementation of
the corresponding indirect operation[.](#4.sentence-3)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5948)
A program that instantiates the definition of
the template indirect<T, Allocator> with
a type for the T parameter that is
a non-object type,
an array type,in_place_t,
a specialization of in_place_type_t, or
a cv-qualified type
is ill-formed[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5959)
The template parameter T of indirect may be an incomplete type[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5963)
The template parameter Allocator of indirect shall meet the *Cpp17Allocator* requirements[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L5967)
If a program declares an explicit or partial specialization of indirect,
the behavior is undefined[.](#8.sentence-1)

29
cppdraft/indirect/hash.md Normal file
View File

@@ -0,0 +1,29 @@
[indirect.hash]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.hash)
### 20.4.1 Class template indirect [[indirect]](indirect#hash)
#### 20.4.1.10 Hash support [indirect.hash]
[🔗](#lib:hash,indirect)
`template<class T, class Allocator>
struct hash<indirect<T, Allocator>>;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6740)
The specialization hash<indirect<T, Allocator>> is enabled ([[unord.hash]](unord.hash "22.10.19Class template hash")) if and only if hash<T> is enabled[.](#1.sentence-1)
When enabled for an object i of type indirect<T, Allocator>,hash<indirect<T, Allocator>>()(i) evaluates to
either the same value as hash<T>()(*i),
if i is not valueless;
otherwise to animplementation-defined
value[.](#1.sentence-2)
The member functions are not guaranteed to be noexcept[.](#1.sentence-3)

85
cppdraft/indirect/obs.md Normal file
View File

@@ -0,0 +1,85 @@
[indirect.obs]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.obs)
### 20.4.1 Class template indirect [[indirect]](indirect#obs)
#### 20.4.1.6 Observers [indirect.obs]
[🔗](#lib:operator*,indirect)
`constexpr const T& operator*() const & noexcept;
constexpr T& operator*() & noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6547)
*Preconditions*: *this is not valueless[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6551)
*Returns*: **p*[.](#2.sentence-1)
[🔗](#lib:operator*,indirect_)
`constexpr const T&& operator*() const && noexcept;
constexpr T&& operator*() && noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6563)
*Preconditions*: *this is not valueless[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6567)
*Returns*: std::move(**p*)[.](#4.sentence-1)
[🔗](#lib:operator-%3e,indirect)
`constexpr const_pointer operator->() const noexcept;
constexpr pointer operator->() noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6579)
*Preconditions*: *this is not valueless[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6583)
*Returns*: *p*[.](#6.sentence-1)
[🔗](#lib:valueless_after_move,indirect)
`constexpr bool valueless_after_move() const noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6594)
*Returns*: true if *this is valueless, otherwise false[.](#7.sentence-1)
[🔗](#lib:get_allocator,indirect)
`constexpr allocator_type get_allocator() const noexcept;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6605)
*Returns*: *alloc*[.](#8.sentence-1)

View File

@@ -0,0 +1,44 @@
[indirect.relops]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.relops)
### 20.4.1 Class template indirect [[indirect]](indirect#relops)
#### 20.4.1.8 Relational operators [indirect.relops]
[🔗](#itemdecl:1)
`template<class U, class AA>
constexpr bool operator==(const indirect& lhs, const indirect<U, AA>& rhs)
noexcept(noexcept(*lhs == *rhs));
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6666)
*Mandates*: The expression *lhs == *rhs is well-formed and
its result is convertible to bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6671)
*Returns*: If lhs is valueless or rhs is valueless,lhs.valueless_after_move() == rhs.valueless_after_move();
otherwise *lhs == *rhs[.](#2.sentence-1)
[🔗](#itemdecl:2)
`template<class U, class AA>
constexpr synth-three-way-result<T, U>
operator<=>(const indirect& lhs, const indirect<U, AA>& rhs);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6687)
*Returns*: If lhs is valueless or rhs is valueless,!lhs.valueless_after_move() <=> !rhs.valueless_after_move();
otherwise*synth-three-way*(*lhs, *rhs)[.](#3.sentence-1)

55
cppdraft/indirect/swap.md Normal file
View File

@@ -0,0 +1,55 @@
[indirect.swap]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.swap)
### 20.4.1 Class template indirect [[indirect]](indirect#swap)
#### 20.4.1.7 Swap [indirect.swap]
[🔗](#lib:swap,indirect)
`constexpr void swap(indirect& other)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6620)
*Preconditions*: Ifallocator_traits<Allocator>::propagate_on_container_swap::value is true, thenAllocator meets the *Cpp17Swappable* requirements[.](#1.sentence-1)
Otherwise get_allocator() == other.
get_allocator() is true[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6628)
*Effects*: Swaps the states of *this and other,
exchanging owned objects or valueless states[.](#2.sentence-1)
If allocator_traits<Allocator>::propagate_on_container_swap::value is true,
then the allocators of *this and other are exchanged by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements")[.](#2.sentence-2)
Otherwise,
the allocators are not swapped[.](#2.sentence-3)
[*Note [1](#note-1)*:
Does not call swap on the owned objects directly[.](#2.sentence-4)
— *end note*]
[🔗](#itemdecl:2)
`constexpr void swap(indirect& lhs, indirect& rhs) noexcept(noexcept(lhs.swap(rhs)));
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6650)
*Effects*: Equivalent to lhs.swap(rhs)[.](#3.sentence-1)

15
cppdraft/indirect/syn.md Normal file
View File

@@ -0,0 +1,15 @@
[indirect.syn]
# 20 Memory management library [[mem]](./#mem)
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.syn)
### 20.4.1 Class template indirect [[indirect]](indirect#syn)
#### 20.4.1.2 Synopsis [indirect.syn]
[🔗](#lib:indirect)
namespace std {template<class T, class Allocator = allocator<T>>class indirect {public:using value_type = T; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; // [[indirect.ctor]](indirect.ctor "20.4.1.3Constructors"), constructorsconstexpr explicit indirect(); constexpr explicit indirect(allocator_arg_t, const Allocator& a); constexpr indirect(const indirect& other); constexpr indirect(allocator_arg_t, const Allocator& a, const indirect& other); constexpr indirect(indirect&& other) noexcept; constexpr indirect(allocator_arg_t, const Allocator& a, indirect&& other)noexcept(*see below*); template<class U = T>constexpr explicit indirect(U&& u); template<class U = T>constexpr explicit indirect(allocator_arg_t, const Allocator& a, U&& u); template<class... Us>constexpr explicit indirect(in_place_t, Us&&... us); template<class... Us>constexpr explicit indirect(allocator_arg_t, const Allocator& a,
in_place_t, Us&&... us); template<class I, class... Us>constexpr explicit indirect(in_place_t, initializer_list<I> ilist, Us&&... us); template<class I, class... Us>constexpr explicit indirect(allocator_arg_t, const Allocator& a,
in_place_t, initializer_list<I> ilist, Us&&... us); // [[indirect.dtor]](indirect.dtor "20.4.1.4Destructor"), destructorconstexpr ~indirect(); // [[indirect.assign]](indirect.assign "20.4.1.5Assignment"), assignmentconstexpr indirect& operator=(const indirect& other); constexpr indirect& operator=(indirect&& other) noexcept(*see below*); template<class U = T>constexpr indirect& operator=(U&& u); // [[indirect.obs]](indirect.obs "20.4.1.6Observers"), observersconstexpr const T& operator*() const & noexcept; constexpr T& operator*() & noexcept; constexpr const T&& operator*() const && noexcept; constexpr T&& operator*() && noexcept; constexpr const_pointer operator->() const noexcept; constexpr pointer operator->() noexcept; constexpr bool valueless_after_move() const noexcept; constexpr allocator_type get_allocator() const noexcept; // [[indirect.swap]](indirect.swap "20.4.1.7Swap"), swapconstexpr void swap(indirect& other) noexcept(*see below*); friend constexpr void swap(indirect& lhs, indirect& rhs) noexcept(*see below*); // [[indirect.relops]](indirect.relops "20.4.1.8Relational operators"), relational operatorstemplate<class U, class AA>friend constexpr bool operator==(const indirect& lhs, const indirect<U, AA>& rhs)noexcept(*see below*); template<class U, class AA>friend constexpr auto operator<=>(const indirect& lhs, const indirect<U, AA>& rhs)-> *synth-three-way-result*<T, U>; // [[indirect.comp.with.t]](indirect.comp.with.t "20.4.1.9Comparison with T"), comparison with Ttemplate<class U>friend constexpr bool operator==(const indirect& lhs, const U& rhs) noexcept(*see below*); template<class U>friend constexpr auto operator<=>(const indirect& lhs, const U& rhs)-> *synth-three-way-result*<T, U>; private: pointer *p*; // *exposition only* Allocator *alloc* = Allocator(); // *exposition only*}; template<class Value> indirect(Value) -> indirect<Value>; template<class Allocator, class Value> indirect(allocator_arg_t, Allocator, Value)-> indirect<Value, typename allocator_traits<Allocator>::template rebind_alloc<Value>>;}