[expected.void.obs]

# 22 General utilities library [[utilities]](./#utilities)

## 22.8 Expected objects [[expected]](expected#void.obs)

### 22.8.7 Partial specialization of expected for void types [[expected.void]](expected.void#obs)

#### 22.8.7.6 Observers [expected.void.obs]

[ð](#lib:operator_bool,expected%3cvoid%3e)

`constexpr explicit operator bool() const noexcept;
constexpr bool has_value() const noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9954)

*Returns*: *has_val*[.](#1.sentence-1)

[ð](#lib:operator*,expected%3cvoid%3e)

`constexpr void operator*() const noexcept;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9965)

*Hardened preconditions*: has_value() is true[.](#2.sentence-1)

[ð](#lib:value,expected%3cvoid%3e)

`constexpr void value() const &;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9976)

*Mandates*: is_copy_constructible_v<E> is true[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9980)

*Throws*: bad_expected_access(error()) if has_value() is false[.](#4.sentence-1)

[ð](#lib:value,expected%3cvoid%3e_)

`constexpr void value() &&;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9991)

*Mandates*: is_copy_constructible_v<E> is true andis_move_constructible_v<E> is true[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L9996)

*Throws*: bad_expected_access(std​::​move(error())) if has_value() is false[.](#6.sentence-1)

[ð](#lib:error,expected%3cvoid%3e)

`constexpr const E& error() const & noexcept;
constexpr E& error() & noexcept;
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10009)

*Hardened preconditions*: has_value() is false[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10013)

*Returns*: *unex*[.](#8.sentence-1)

[ð](#lib:error,expected%3cvoid%3e_)

`constexpr E&& error() && noexcept;
constexpr const E&& error() const && noexcept;
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10025)

*Hardened preconditions*: has_value() is false[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10029)

*Returns*: std​::​move(*unex*)[.](#10.sentence-1)

[ð](#lib:error_or,expected%3cvoid%3e)

`template<class G = E> constexpr E error_or(G&& e) const &;
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10040)

*Mandates*: is_copy_constructible_v<E> is true andis_convertible_v<G, E> is true[.](#11.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10045)

*Returns*: std​::​forward<G>(e) if has_value() is true,error() otherwise[.](#12.sentence-1)

[ð](#lib:error_or,expected%3cvoid%3e_)

`template<class G = E> constexpr E error_or(G&& e) &&;
`

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10057)

*Mandates*: is_move_constructible_v<E> is true andis_convertible_v<G, E> is true[.](#13.sentence-1)

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L10062)

*Returns*: std​::​forward<G>(e) if has_value() is true,std​::​move(error()) otherwise[.](#14.sentence-1)
