Constructors

Synopses

Declared in <beman/optional/optional.hpp>

Default constructs an empty optional.

constexpr
optional() noexcept;

Copy constructs the value from rhs if it has one.

constexpr
optional(optional const& other)
requires std::is_copy_constructible_v<T> && std::is_trivially_copy_constructible_v<T> = default;

Copy constructs the value from rhs if it has one.

constexpr
optional(optional const& rhs)
requires std::is_copy_constructible_v<T> && (!std::is_trivially_copy_constructible_v<T>);

Constructs the value from rhs if it has one.

template<class U>
constexpr
optional(optional<U> const& rhs)
requires (detail::enable_from_other<T, U, const U&>);

Move constructs the value from rhs if it has one.

constexpr
optional(optional&& other)
requires std::is_move_constructible_v<T> && std::is_trivially_move_constructible_v<T> = default;

Move constructs the value from rhs if it has one.

constexpr
optional(optional&& rhs) noexcept(std::is_nothrow_move_constructible_v<T>)
requires std::is_move_constructible_v<T> && (!std::is_trivially_move_constructible_v<T>);

Constructs the value from rhs if it has one.

template<class U>
constexpr
optional(optional<U>&& rhs)
requires (detail::enable_from_other<T, U, U &&>);

Constructs an empty optional.

constexpr
optional(nullopt_t value) noexcept;

Constructs the value from u, forwarding it if necessary.

template<class U = T>
constexpr
optional(U&& u)
requires detail::enable_forward_value<T, U>;

Constructs the value in‐place using the given arguments.

template<class... Args>
constexpr
optional(
    in_place_t,
    Args...&&... args)
requires std::is_constructible_v<T, Args...>;

Constructs the value in‐place using the given arguments.

template<
    class U,
    class... Args>
constexpr
optional(
    in_place_t,
    std::initializer_list<U> il,
    Args...&&... args)
requires std::is_constructible_v<T, std::initializer_list<U>&, Args&&...>;

Template Parameters

Name

Description

U

Created with MrDocs