Files
2025-10-25 03:02:53 +03:00

8.0 KiB
Raw Permalink Blame History

[expected.void.cons]

22 General utilities library [utilities]

22.8 Expected objects [expected]

22.8.7 Partial specialization of expected for void types [expected.void]

22.8.7.2 Constructors [expected.void.cons]

🔗

constexpr expected() noexcept;

1

#

Postconditions: has_value() is true.

🔗

constexpr expected(const expected& rhs);

2

#

Effects: If rhs.has_value() is false, direct-non-list-initializes unex with rhs.error().

3

#

Postconditions: rhs.has_value() == this->has_value().

4

#

Throws: Any exception thrown by the initialization of unex.

5

#

Remarks: This constructor is defined as deleted unless is_copy_constructible_v is true.

6

#

This constructor is trivial if is_trivially_copy_constructible_v is true.

🔗

constexpr expected(expected&& rhs) noexcept(is_nothrow_move_constructible_v<E>);

7

#

Constraints: is_move_constructible_v is true.

8

#

Effects: If rhs.has_value() is false, direct-non-list-initializes unex with std::move(rhs.error()).

9

#

Postconditions: rhs.has_value() is unchanged;rhs.has_value() == this->has_value() is true.

10

#

Throws: Any exception thrown by the initialization of unex.

11

#

Remarks: This constructor is trivial if is_trivially_move_constructible_v is true.

🔗

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

#

Let GF be const G& for the first overload andG for the second overload.

13

#

Constraints:

is_void_v is true; and

is_constructible_v<E, GF> is true; and

is_constructible_v<unexpected, expected<U, G>&> is false; and

is_constructible_v<unexpected, expected<U, G>> is false; and

is_constructible_v<unexpected, const expected<U, G>&> is false; and

is_constructible_v<unexpected, const expected<U, G>> is false.

14

#

Effects: If rhs.has_value() is false, direct-non-list-initializes unex with std::forward(rhs.error()).

15

#

Postconditions: rhs.has_value() is unchanged;rhs.has_value() == this->has_value() is true.

16

#

Throws: Any exception thrown by the initialization of unex.

🔗

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

#

Let GF be const G& for the first overload andG for the second overload.

18

#

Constraints: is_constructible_v<E, GF> is true.

19

#

Effects: Direct-non-list-initializes unex with std::forward(e.error()).

20

#

Postconditions: has_value() is false.

21

#

Throws: Any exception thrown by the initialization of unex.

🔗

constexpr explicit expected(in_place_t) noexcept;

22

#

Postconditions: has_value() is true.

🔗

template<class... Args> constexpr explicit expected(unexpect_t, Args&&... args);

23

#

Constraints: is_constructible_v<E, Args...> is true.

24

#

Effects: Direct-non-list-initializes unex with std::forward(args)....

25

#

Postconditions: has_value() is false.

26

#

Throws: Any exception thrown by the initialization of unex.

🔗

template<class U, class... Args> constexpr explicit expected(unexpect_t, initializer_list<U> il, Args&&... args);

27

#

Constraints: is_constructible_v<E, initializer_list&, Args...> is true.

28

#

Effects: Direct-non-list-initializes unex with il, std::forward(args)....

29

#

Postconditions: has_value() is false.

30

#

Throws: Any exception thrown by the initialization of unex.