beman::optional::make_optional

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>;
» more...

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...>;
» more...

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...>;
» more...

Return Value

  • An engaged optional whose contained value is constructed from t.
  • An engaged optional<T> holding the in-place constructed value.

Parameters

NameDescription
tThe value to store in the returned optional.
argsThe arguments forwarded to the constructor of T.
ilThe initializer list forwarded to the constructor of T.