make_optional overloads

Synopses

Declared in <beman/optional/optional.hpp>

Creates an optional holding a decayed copy of the given value.

template<
    int = 0,
    class T>
constexpr
optional<std::decay_t<T>>
make_optional(T&& t) noexcept(/* see-below */)
requires std::is_constructible_v<std::decay_t<T>, T>;

Creates an optional<T> constructing the value in‐place from the given arguments.

template<
    typename T,
    typename... Args>
constexpr
optional<T>
make_optional(Args&&... args) noexcept(/* see-below */)
requires std::is_constructible_v<T, Args...>;

Creates an optional<T> constructing the value in‐place from an initializer list and arguments.

template<
    typename T,
    typename U,
    typename... Args>
constexpr
optional<T>
make_optional(
    std::initializer_list<U> il,
    Args&&... args) noexcept(/* see-below */)
requires std::is_constructible_v<T, std::initializer_list<U>&, Args...>;

Return Value

  • An engaged optional whose contained value is constructed from t.

  • An engaged optional<T> holding the in‐place constructed value.

Parameters

Name

Description

t

The value to store in the returned optional.

args

The arguments forwarded to the constructor of T.

il

The initializer list forwarded to the constructor of T.

Created with MrDocs