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

148
cppdraft/variant/mod.md Normal file
View File

@@ -0,0 +1,148 @@
[variant.mod]
# 22 General utilities library [[utilities]](./#utilities)
## 22.6 Variants [[variant]](variant#mod)
### 22.6.3 Class template variant [[variant.variant]](variant.variant#variant.mod)
#### 22.6.3.5 Modifiers [variant.mod]
[🔗](#lib:emplace,variant)
`template<class T, class... Args> constexpr T& emplace(Args&&... args);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6244)
*Constraints*: is_constructible_v<T, Args...> is true, andT occurs exactly once in Types[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6249)
*Effects*: Equivalent to:return emplace<I>(std::forward<Args>(args)...); where I is the zero-based index of T in Types[.](#2.sentence-1)
[🔗](#lib:emplace,variant_)
`template<class T, class U, class... Args>
constexpr T& emplace(initializer_list<U> il, Args&&... args);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6265)
*Constraints*: is_constructible_v<T, initializer_list<U>&, Args...> is true,
and T occurs exactly once in Types[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6270)
*Effects*: Equivalent to:return emplace<I>(il, std::forward<Args>(args)...); where I is the zero-based index of T in Types[.](#4.sentence-1)
[🔗](#lib:emplace,variant__)
`template<size_t I, class... Args>
constexpr variant_alternative_t<I, variant<Types...>>& emplace(Args&&... args);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6286)
*Mandates*: I < sizeof...(Types)[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6290)
*Constraints*: is_constructible_v<TI, Args...> is true[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6294)
*Effects*: Destroys the currently contained value if valueless_by_exception() is false[.](#7.sentence-1)
Then direct-non-list-initializes the contained value of type TI with the arguments std::forward<Args>(args)...[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6301)
*Postconditions*: index() is I[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6305)
*Returns*: A reference to the new contained value[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6309)
*Throws*: Any exception thrown during the initialization of the contained value[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6313)
*Remarks*: If an exception is thrown during the initialization of the contained value,
the variant is permitted to not hold a value[.](#11.sentence-1)
[🔗](#lib:emplace,variant___)
`template<size_t I, class U, class... Args>
constexpr variant_alternative_t<I, variant<Types...>>&
emplace(initializer_list<U> il, Args&&... args);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6327)
*Mandates*: I < sizeof...(Types)[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6331)
*Constraints*: is_constructible_v<TI, initializer_list<U>&, Args...> is true[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6335)
*Effects*: Destroys the currently contained value if valueless_by_exception() is false[.](#14.sentence-1)
Then direct-non-list-initializes the contained value of type TI with il, std::forward<Args>(args)...[.](#14.sentence-2)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6342)
*Postconditions*: index() is I[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6346)
*Returns*: A reference to the new contained value[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6350)
*Throws*: Any exception thrown during the initialization of the contained value[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L6354)
*Remarks*: If an exception is thrown during the initialization of the contained value,
the variant is permitted to not hold a value[.](#18.sentence-1)