[expected.un.general]

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

## 22.8 Expected objects [[expected]](expected#un.general)

### 22.8.3 Class template unexpected [[expected.unexpected]](expected.unexpected#expected.un.general)

#### 22.8.3.1 General [expected.un.general]

[1](#1)

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

Subclause [[expected.unexpected]](expected.unexpected "22.8.3 Class template unexpected") describes the class template unexpected that represents unexpected objects stored in expected objects[.](#1.sentence-1)

[ð](#lib:unexpected)

namespace std {template<class E>class unexpected {public:// [[expected.un.cons]](expected.un.cons "22.8.3.2 Constructors"), constructorsconstexpr unexpected(const unexpected&) = default; constexpr unexpected(unexpected&&) = default; template<class Err = E>constexpr explicit unexpected(Err&&); template<class... Args>constexpr explicit unexpected(in_place_t, Args&&...); template<class U, class... Args>constexpr explicit unexpected(in_place_t, initializer_list<U>, Args&&...); constexpr unexpected& operator=(const unexpected&) = default; constexpr unexpected& operator=(unexpected&&) = default; constexpr const E& error() const & noexcept; constexpr E& error() & noexcept; constexpr const E&& error() const && noexcept; constexpr E&& error() && noexcept; constexpr void swap(unexpected& other) noexcept(*see below*); template<class E2>friend constexpr bool operator==(const unexpected&, const unexpected<E2>&); friend constexpr void swap(unexpected& x, unexpected& y) noexcept(noexcept(x.swap(y))); private: E *unex*; // *exposition only*}; template<class E> unexpected(E) -> unexpected<E>;}

[2](#2)

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

A program that instantiates the definition of unexpected for
a non-object type,
an array type,
a specialization of unexpected, or
a cv-qualified type
is ill-formed[.](#2.sentence-1)
