Constructors

Synopses

Declared in <beman/optional/optional.hpp>

Default constructor.

constexpr
optional() noexcept = default;

Copy constructor.

constexpr
optional(optional const& rhs) noexcept = default;

Constructs an empty optional.

constexpr
optional(nullopt_t value) noexcept;

Constructs an optional from another optional of type U

template<class U>
requires (std::is_constructible_v<T&, U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
                 !std::is_same_v<T&, U> && detail::reference_constructs_from_temporary_v<T&, U&>)
constexpr
optional(optional<U>& rhs) = delete;

Constructs an optional from another optional of type U.

template<class U>
requires (std::is_constructible_v<T&, U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
             !std::is_same_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, U&>)
constexpr
optional(optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T &, U &>);

Constructs an optional from another optional of type U

template<class U>
requires (std::is_constructible_v<T&, const U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
                 !std::is_same_v<T&, U> && detail::reference_constructs_from_temporary_v<T&, const U&>)
constexpr
optional(optional<U> const& rhs) = delete;

Constructs an optional from another optional of type U.

template<class U>
requires (std::is_constructible_v<T&, const U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
             !std::is_same_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, const U&>)
constexpr
optional(optional<U> const& rhs) noexcept(std::is_nothrow_constructible_v<T &, const U &>);

Constructs an optional from a U, but deletes the constructor if

template<class U>
requires (std::is_constructible_v<T&, U> && !(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
                 !(std::is_same_v<std::remove_cvref_t<U>, optional>) &&
                 detail::reference_constructs_from_temporary_v<T&, U>)
constexpr
optional(U&& u) = delete;

Construct from a U

template<class U>
requires (std::is_constructible_v<T&, U> && !(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
                 !(std::is_same_v<std::remove_cvref_t<U>, optional>) &&
                 !detail::reference_constructs_from_temporary_v<T&, U>)
constexpr
optional(U&& u) noexcept(std::is_nothrow_constructible_v<T &, U>);

Constructs an optional from another optional of type U

template<class U>
requires (std::is_constructible_v<T&, U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
                 !std::is_same_v<T&, U> && detail::reference_constructs_from_temporary_v<T&, U>)
constexpr
optional(optional<U>&& rhs) = delete;

Constructs an optional from another optional of type U.

template<class U>
requires (std::is_constructible_v<T&, U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
             !std::is_same_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, U>)
constexpr
optional(optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, U>));

Constructs an optional from another optional of type U

template<class U>
requires (std::is_constructible_v<T&, const U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
                 !std::is_same_v<T&, U> && detail::reference_constructs_from_temporary_v<T&, const U>)
constexpr
optional(optional<U> const&& rhs) = delete;

Constructs an optional from another optional of type U.

template<class U>
requires (std::is_constructible_v<T&, const U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
             !std::is_same_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, const U>)
constexpr
optional(optional<U> const&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, const U>));

In‐place constructor.

template<class Arg>
requires (std::is_constructible_v<T&, Arg> && !detail::reference_constructs_from_temporary_v<T&, Arg>)
constexpr
optional(
    in_place_t,
    Arg&& arg);

Template Parameters

Name

Description

U

Arg

Parameters

Name

Description

rhs

u

arg

Created with MrDocs