[refwrap.general]

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

## 22.10 Function objects [[function.objects]](function.objects#refwrap.general)

### 22.10.6 Class template reference_wrapper [[refwrap]](refwrap#general)

#### 22.10.6.1 General [refwrap.general]

[ð](#lib:reference_wrapper)

namespace std {template<class T> class reference_wrapper {public:// typesusing type = T; // [[refwrap.const]](refwrap.const "22.10.6.2 Constructors"), constructorstemplate<class U>constexpr reference_wrapper(U&&) noexcept(*see below*); constexpr reference_wrapper(const reference_wrapper& x) noexcept; // [[refwrap.assign]](refwrap.assign "22.10.6.3 Assignment"), assignmentconstexpr reference_wrapper& operator=(const reference_wrapper& x) noexcept; // [[refwrap.access]](refwrap.access "22.10.6.4 Access"), accessconstexpr operator T& () const noexcept; constexpr T& get() const noexcept; // [[refwrap.invoke]](refwrap.invoke "22.10.6.5 Invocation"), invocationtemplate<class... ArgTypes>constexpr invoke_result_t<T&, ArgTypes...> operator()(ArgTypes&&...) constnoexcept(is_nothrow_invocable_v<T&, ArgTypes...>); // [[refwrap.comparisons]](refwrap.comparisons "22.10.6.6 Comparisons"), comparisonsfriend constexpr bool operator==(reference_wrapper, reference_wrapper); friend constexpr bool operator==(reference_wrapper, const T&); friend constexpr bool operator==(reference_wrapper, reference_wrapper<const T>); friend constexpr auto operator<=>(reference_wrapper, reference_wrapper); friend constexpr auto operator<=>(reference_wrapper, const T&); friend constexpr auto operator<=>(reference_wrapper, reference_wrapper<const T>); }; template<class T> reference_wrapper(T&) -> reference_wrapper<T>;}

[1](#1)

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

reference_wrapper<T> is a [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") wrapper
around a reference to an object or function of type T[.](#1.sentence-1)

[2](#2)

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

reference_wrapper<T> is
a trivially copyable type ([[basic.types.general]](basic.types.general#term.trivially.copyable.type "6.9.1 General"))[.](#2.sentence-1)

[3](#3)

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

The template parameter T of reference_wrapper may be an incomplete type[.](#3.sentence-1)

[*Note [1](#note-1)*:

Using the comparison operators described in [[refwrap.comparisons]](refwrap.comparisons "22.10.6.6 Comparisons") with T being an incomplete type
can lead to an ill-formed program
with no diagnostic required ([[temp.point]](temp.point "13.8.4.1 Point of instantiation"), [[temp.constr.atomic]](temp.constr.atomic "13.5.2.3 Atomic constraints"))[.](#3.sentence-2)

â *end note*]
