[optional.ref.ctor]

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

## 22.5 Optional objects [[optional]](optional#ref.ctor)

### 22.5.4 Partial specialization of optional for reference types [[optional.optional.ref]](optional.optional.ref#optional.ref.ctor)

#### 22.5.4.2 Constructors [optional.ref.ctor]

[ð](#itemdecl:1)

`template<class Arg>
  constexpr explicit optional(in_place_t, Arg&& arg);
`

[1](#1)

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

*Constraints*: 

- [(1.1)](#1.1)

is_constructible_v<T&, Arg> is true, and

- [(1.2)](#1.2)

reference_constructs_from_temporary_v<T&, Arg> is false[.](#1.sentence-1)

[2](#2)

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

*Effects*: Equivalent to: *convert-ref-init-val*(std​::​forward<Arg>(arg))[.](#2.sentence-1)

[3](#3)

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

*Postconditions*: *this contains a value[.](#3.sentence-1)

[ð](#itemdecl:2)

`template<class U>
  constexpr explicit(!is_convertible_v<U, T&>)
  optional(U&& u) noexcept(is_nothrow_constructible_v<T&, U>);
`

[4](#4)

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

*Constraints*: 

- [(4.1)](#4.1)

is_same_v<remove_cvref_t<U>, optional> is false,

- [(4.2)](#4.2)

is_same_v<remove_cvref_t<U>, in_place_t> is false, and

- [(4.3)](#4.3)

is_constructible_v<T&, U> is true[.](#4.sentence-1)

[5](#5)

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

*Effects*: Equivalent to: *convert-ref-init-val*(std​::​forward<U>(u))[.](#5.sentence-1)

[6](#6)

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

*Postconditions*: *this contains a value[.](#6.sentence-1)

[7](#7)

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

*Remarks*: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U> is true[.](#7.sentence-1)

[ð](#itemdecl:3)

`template<class U>
  constexpr explicit(!is_convertible_v<U&, T&>)
  optional(optional<U>& rhs) noexcept(is_nothrow_constructible_v<T&, U&>);
`

[8](#8)

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

*Constraints*: 

- [(8.1)](#8.1)

is_same_v<remove_cv_t<T>, optional<U>> is false,

- [(8.2)](#8.2)

is_same_v<T&, U> is false, and

- [(8.3)](#8.3)

is_constructible_v<T&, U&> is true[.](#8.sentence-1)

[9](#9)

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

*Effects*: Equivalent to:if (rhs.has_value()) *convert-ref-init-val*(*rhs);

[10](#10)

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

*Remarks*: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U&> is true[.](#10.sentence-1)

[ð](#itemdecl:4)

`template<class U>
  constexpr explicit(!is_convertible_v<const U&, T&>)
  optional(const optional<U>& rhs) noexcept(is_nothrow_constructible_v<T&, const U&>);
`

[11](#11)

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

*Constraints*: 

- [(11.1)](#11.1)

is_same_v<remove_cv_t<T>, optional<U>> is false,

- [(11.2)](#11.2)

is_same_v<T&, U> is false, and

- [(11.3)](#11.3)

is_constructible_v<T&, const U&> is true[.](#11.sentence-1)

[12](#12)

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

*Effects*: Equivalent to:if (rhs.has_value()) *convert-ref-init-val*(*rhs);

[13](#13)

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

*Remarks*: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, const U&> is true[.](#13.sentence-1)

[ð](#itemdecl:5)

`template<class U>
  constexpr explicit(!is_convertible_v<U, T&>)
  optional(optional<U>&& rhs) noexcept(is_nothrow_constructible_v<T&, U>);
`

[14](#14)

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

*Constraints*: 

- [(14.1)](#14.1)

is_same_v<remove_cv_t<T>, optional<U>> is false,

- [(14.2)](#14.2)

is_same_v<T&, U> is false, and

- [(14.3)](#14.3)

is_constructible_v<T&, U> is true[.](#14.sentence-1)

[15](#15)

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

*Effects*: Equivalent to:if (rhs.has_value()) *convert-ref-init-val*(*std::move(rhs));

[16](#16)

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

*Remarks*: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U> is true[.](#16.sentence-1)

[ð](#itemdecl:6)

`template<class U>
  constexpr explicit(!is_convertible_v<const U, T&>)
  optional(const optional<U>&& rhs) noexcept(is_nothrow_constructible_v<T&, const U>);
`

[17](#17)

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

*Constraints*: 

- [(17.1)](#17.1)

is_same_v<remove_cv_t<T>, optional<U>> is false,

- [(17.2)](#17.2)

is_same_v<T&, U> is false, and

- [(17.3)](#17.3)

is_constructible_v<T&, const U> is true[.](#17.sentence-1)

[18](#18)

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

*Effects*: Equivalent to:if (rhs.has_value()) *convert-ref-init-val*(*std::move(rhs));

[19](#19)

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

*Remarks*: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, const U> is true[.](#19.sentence-1)
