[optional.ref.ctor] (original) (raw)

22 General utilities library [utilities]

22.5 Optional objects [optional]

22.5.4 Partial specialization of optional for reference types [optional.optional.ref]

22.5.4.2 Constructors [optional.ref.ctor]

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

Constraints:

Effects: Equivalent to: convert-ref-init-val(std​::​forward<Arg>(arg)).

Postconditions: *this contains a value.

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

Constraints:

Effects: Equivalent to: convert-ref-init-val(std​::​forward<U>(u)).

Postconditions: *this contains a value.

Remarks: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U> is true.

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

Constraints:

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

Remarks: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U&> is true.

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

Constraints:

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

Remarks: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, const U&> is true.

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

Constraints:

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

Remarks: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, U> is true.

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

Constraints:

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

Remarks: This constructor is defined as deleted ifreference_constructs_from_temporary_v<T&, const U> is true.