Files
cppdraft_translate/cppdraft/expected/void/cons.md
2025-10-25 03:02:53 +03:00

268 lines
8.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[expected.void.cons]
# 22 General utilities library [[utilities]](./#utilities)
## 22.8 Expected objects [[expected]](expected#void.cons)
### 22.8.7 Partial specialization of expected for void types [[expected.void]](expected.void#cons)
#### 22.8.7.2 Constructors [expected.void.cons]
[🔗](#lib:expected%3cvoid%3e,constructor)
`constexpr expected() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9539)
*Postconditions*: has_value() is true[.](#1.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor_)
`constexpr expected(const expected& rhs);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9550)
*Effects*: If rhs.has_value() is false,
direct-non-list-initializes *unex* with rhs.error()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9555)
*Postconditions*: rhs.has_value() == this->has_value()[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9559)
*Throws*: Any exception thrown by the initialization of *unex*[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9563)
*Remarks*: This constructor is defined as deleted
unless is_copy_constructible_v<E> is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9568)
This constructor is trivial
if is_trivially_copy_constructible_v<E> is true[.](#6.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor__)
`constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v<E>);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9579)
*Constraints*: is_move_constructible_v<E> is true[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9583)
*Effects*: If rhs.has_value() is false,
direct-non-list-initializes *unex* with std::move(rhs.error())[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9588)
*Postconditions*: rhs.has_value() is unchanged;rhs.has_value() == this->has_value() is true[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9593)
*Throws*: Any exception thrown by the initialization of *unex*[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9597)
*Remarks*: This constructor is trivial
if is_trivially_move_constructible_v<E> is true[.](#11.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor___)
`template<class U, class G>
constexpr explicit(!is_convertible_v<const G&, E>) expected(const expected<U, G>& rhs);
template<class U, class G>
constexpr explicit(!is_convertible_v<G, E>) expected(expected<U, G>&& rhs);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9612)
Let GF be const G& for the first overload andG for the second overload[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9616)
*Constraints*:
- [(13.1)](#13.1)
is_void_v<U> is true; and
- [(13.2)](#13.2)
is_constructible_v<E, GF> is true; and
- [(13.3)](#13.3)
is_constructible_v<unexpected<E>, expected<U, G>&> is false; and
- [(13.4)](#13.4)
is_constructible_v<unexpected<E>, expected<U, G>> is false; and
- [(13.5)](#13.5)
is_constructible_v<unexpected<E>, const expected<U, G>&> is false; and
- [(13.6)](#13.6)
is_constructible_v<unexpected<E>, const expected<U, G>> is false[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9637)
*Effects*: If rhs.has_value() is false,
direct-non-list-initializes *unex* with std::forward<GF>(rhs.error())[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9643)
*Postconditions*: rhs.has_value() is unchanged;rhs.has_value() == this->has_value() is true[.](#15.sentence-1)
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9648)
*Throws*: Any exception thrown by the initialization of *unex*[.](#16.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor____)
`template<class G>
constexpr explicit(!is_convertible_v<const G&, E>) expected(const unexpected<G>& e);
template<class G>
constexpr explicit(!is_convertible_v<G, E>) expected(unexpected<G>&& e);
`
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9662)
Let GF be const G& for the first overload andG for the second overload[.](#17.sentence-1)
[18](#18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9666)
*Constraints*: is_constructible_v<E, GF> is true[.](#18.sentence-1)
[19](#19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9670)
*Effects*: Direct-non-list-initializes *unex* with std::forward<GF>(e.error())[.](#19.sentence-1)
[20](#20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9675)
*Postconditions*: has_value() is false[.](#20.sentence-1)
[21](#21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9679)
*Throws*: Any exception thrown by the initialization of *unex*[.](#21.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor_____)
`constexpr explicit expected(in_place_t) noexcept;
`
[22](#22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9690)
*Postconditions*: has_value() is true[.](#22.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor______)
`template<class... Args>
constexpr explicit expected(unexpect_t, Args&&... args);
`
[23](#23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9702)
*Constraints*: is_constructible_v<E, Args...> is true[.](#23.sentence-1)
[24](#24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9706)
*Effects*: Direct-non-list-initializes *unex* with std::forward<Args>(args)...[.](#24.sentence-1)
[25](#25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9711)
*Postconditions*: has_value() is false[.](#25.sentence-1)
[26](#26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9715)
*Throws*: Any exception thrown by the initialization of *unex*[.](#26.sentence-1)
[🔗](#lib:expected%3cvoid%3e,constructor_______)
`template<class U, class... Args>
constexpr explicit expected(unexpect_t, initializer_list<U> il, Args&&... args);
`
[27](#27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9727)
*Constraints*: is_constructible_v<E, initializer_list<U>&, Args...> is true[.](#27.sentence-1)
[28](#28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9731)
*Effects*: Direct-non-list-initializes *unex* with il, std::forward<Args>(args)...[.](#28.sentence-1)
[29](#29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9736)
*Postconditions*: has_value() is false[.](#29.sentence-1)
[30](#30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9740)
*Throws*: Any exception thrown by the initialization of *unex*[.](#30.sentence-1)