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

152
cppdraft/any/modifiers.md Normal file
View File

@@ -0,0 +1,152 @@
[any.modifiers]
# 22 General utilities library [[utilities]](./#utilities)
## 22.7 Storage for any type [[any]](any#modifiers)
### 22.7.4 Class any [[any.class]](any.class#any.modifiers)
#### 22.7.4.4 Modifiers [any.modifiers]
[🔗](#lib:emplace,any)
`template<class T, class... Args>
decay_t<T>& emplace(Args&&... args);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7390)
Let VT be decay_t<T>[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7393)
*Constraints*: is_copy_constructible_v<VT> is true andis_constructible_v<VT, Args...> is true[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7398)
*Preconditions*: VT meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7402)
*Effects*: Calls reset()[.](#4.sentence-1)
Then direct-non-list-initializes the contained value of type VT with std::forward<Args>(args)...[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7408)
*Postconditions*: *this contains a value[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7412)
*Returns*: A reference to the new contained value[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7416)
*Throws*: Any exception thrown by the selected constructor of VT[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7420)
*Remarks*: If an exception is thrown during the call to VT's constructor,*this does not contain a value, and any previously contained value
has been destroyed[.](#8.sentence-1)
[🔗](#lib:emplace,any_)
`template<class T, class U, class... Args>
decay_t<T>& emplace(initializer_list<U> il, Args&&... args);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7434)
Let VT be decay_t<T>[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7437)
*Constraints*: is_copy_constructible_v<VT> is true andis_constructible_v<VT, initializer_list<U>&, Args...> is true[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7442)
*Preconditions*: VT meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7446)
*Effects*: Calls reset()[.](#12.sentence-1)
Then direct-non-list-initializes the contained value
of type VT with il, std::forward<Args>(args)...[.](#12.sentence-2)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7451)
*Postconditions*: *this contains a value[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7455)
*Returns*: A reference to the new contained value[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7459)
*Throws*: Any exception thrown by the selected constructor of VT[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7463)
*Remarks*: If an exception is thrown during the call to VT's constructor,*this does not contain a value, and any previously contained value
has been destroyed[.](#16.sentence-1)
[🔗](#lib:reset,any)
`void reset() noexcept;
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7476)
*Effects*: If has_value() is true, destroys the contained value[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7480)
*Postconditions*: has_value() is false[.](#18.sentence-1)
[🔗](#lib:swap,any)
`void swap(any& rhs) noexcept;
`
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L7492)
*Effects*: Exchanges the states of *this and rhs[.](#19.sentence-1)