Reference

Namespaces

Name
beman

beman namespace

Namespaces

Name
optional

beman::optional namespace

Types

NameDescription
bad_optional_access Exception thrown when trying to access the value of an empty optional
in_place_t Tag type for in-place construction
nullopt_t Tag type for empty optional construction
optional Optional Objects
optional<T&> A specialization of optional for references.

Functions

NameDescription
make_optional Make an optional
swap Swap
operator== Equality operators
operator!= Inequality operators
operator< Less-than operators
operator<= Less-than-or-equal operators
operator> Greater-than operators
operator>= Greater-than-or-equal operators
operator<=> Three-way comparison operators

Variables

NameDescription
in_place Tag for in-place construction
nullopt Tag to disengage optional objects.

Concepts

NameDescription
is_derived_from_optional Concept for checking if derived from optional.

Namespaces

Name
optional

Types

NameDescription
bad_optional_access Exception thrown when trying to access the value of an empty optional
in_place_t Tag type for in-place construction
nullopt_t Tag type for empty optional construction
optional Optional Objects
optional<T&> A specialization of optional for references.

Functions

NameDescription
make_optional Make an optional
swap Swap
operator== Equality operators
operator!= Inequality operators
operator< Less-than operators
operator<= Less-than-or-equal operators
operator> Greater-than operators
operator>= Greater-than-or-equal operators
operator<=> Three-way comparison operators

Variables

NameDescription
in_place Tag for in-place construction
nullopt Tag to disengage optional objects.

Concepts

NameDescription
is_derived_from_optional Concept for checking if derived from optional.

Exception thrown when trying to access the value of an empty optional

Synopsis

Declared in <beman/optional/optional.hpp>
class bad_optional_access
    : public std::exception

Base Classes

Name Description
std::exception

Member Functions

NameDescription
bad_optional_access [constructor]Construct a new bad optional access object
operator=
what [virtual]Get the error message for bad optional access

Construct a new bad optional access object

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
bad_optional_access() = default;

Synopsis

Declared in <__exception/exception.h>
[[__visibility__, __exclude_from_explicit_instantiation__, __abi_tag__]]
constexpr
exception&
operator=(exception const& value) noexcept = default;

Get the error message for bad optional access

Synopsis

Declared in <beman/optional/optional.hpp>
virtual
char const*
what() const noexcept;

Return Value

const char*

Tag type for in-place construction

Synopsis

Declared in <beman/optional/optional.hpp>
struct in_place_t;

Member Functions

NameDescription
in_place_t [constructor]Default constructor

Default constructor

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
explicit
in_place_t() = default;

Tag type for empty optional construction

Synopsis

Declared in <beman/optional/optional.hpp>
struct nullopt_t;

Enums

NameDescription
Tag Tag enum for nullopt_t construction

Member Functions

NameDescription
nullopt_t [constructor]Construct a new nullopt_t object

Tag enum for nullopt_t construction

Synopsis

Declared in <beman/optional/optional.hpp>
enum class Tag : int;

Members

NameDescription
tag the tag value for nullopt_t::Tag

Construct a new nullopt_t object

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
explicit
nullopt_t(Tag value) noexcept;

Description

constexpr for nullopt_t to be literal.

Parameters

Name Description
value The object to construct from

Optional Objects

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
class optional;

Types

NameDescription
const_iterator Type alias for the const iterator type of the optional.
iterator Type alias for the iterator type of the optional.
value_type Type alias for the value type contained in the optional.

Member Functions

NameDescription
optional [constructor]Constructors
~optional [destructor]Destructors
operator= Assignment operators
and_then Applies a function to the contained value if there is one.
begin begin overloads
emplace emplace overloads
end end overloads
has_value Returns whether or not the optional has a value.
operator* Returns a reference to the contained value.
operator-> Returns a pointer to the contained value.
or_else or_else overloads
reset Resets the optional to an empty state, destroying the contained value if there is one.
swap Swaps this optional with the other.
transform Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.
value Returns a reference to the contained value.
value_or Returns the contained value if there is one, otherwise returns u.
operator bool Converts the optional to a boolean indicating whether it has a value.

Data Members

NameDescription
_ [variant member]The empty state of the optional.
value_ [variant member]The contained value of the optional.

Friends

|===
Name Description
optional Optional Objects

Non-Member Functions

Name Description
make_optionalMake an optional
operator!=Inequality operator
operator!=Inequality operator
operator<Less-than operator
operator<Less-than operator
operator<=Less-than-or-equal operator
operator<=Less-than-or-equal operator
operator<=>Three-way comparison operator
operator<=>Three-way comparison operator
operator<=>Three-way comparison operator
operator==Equality operator
operator==Equality operator
operator==Equality operator
operator>Greater-than operator
operator>Greater-than operator
operator>=Greater-than-or-equal operator
operator>=Greater-than-or-equal operator
swapSwap

Type alias for the const iterator type of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
using const_iterator = /* implementation-defined */::contiguous_iterator<T const, optional>;

Description

Since P3168R2: Give std::optional Range Support.

Type alias for the iterator type of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
using iterator = /* implementation-defined */::contiguous_iterator<T, optional>;

Description

Since P3168R2: Give std::optional Range Support.

Type alias for the value type contained in the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
using value_type = T;

Constructors

Synopses

Declared in <beman/optional/optional.hpp>

Default constructs an empty optional.

constexpr
optional() noexcept;
» more...

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

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

Constructs the value from rhs if it has one.

template<class U>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(optional<U> const& rhs)
requires (detail::enable_from_other<T, U, const U&>);
» more...

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

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

Constructs the value from rhs if it has one.

template<class U>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(optional<U>&& rhs)
requires (detail::enable_from_other<T, U, U &&>);
» more...

Constructs an empty optional.

constexpr
optional(nullopt_t value) noexcept;
» more...

Constructs the value from u, forwarding it if necessary.

template<class U = T>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(U&& u)
requires detail::enable_forward_value<T, U>;
» more...

Constructs the value in-place using the given arguments.

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

Constructs the value in-place using the given arguments.

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

Parameters

Name Description
args The arguments to use for in-place construction.
il The initializer list to use for in-place construction.

Default constructs an empty optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional() noexcept;

Copy constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(optional const& other)
requires std::is_copy_constructible_v<T> && std::is_trivially_copy_constructible_v<T> = default;

Description

Defaulted if T is trivially copy constructible.

Parameters

Name Description
other The object to copy construct from

Copy constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(optional const& rhs)
requires std::is_copy_constructible_v<T> && (!std::is_trivially_copy_constructible_v<T>);

Parameters

Name Description
rhs The object to copy construct from

Constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(optional<U> const& rhs)
requires (detail::enable_from_other<T, U, const U&>);

Description

Converting copy constructor.

Parameters

Name Description
rhs The object to copy construct from

Move constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(optional&& other)
requires std::is_move_constructible_v<T> && std::is_trivially_move_constructible_v<T> = default;

Description

Defaulted if T is trivially move constructible.

Parameters

Name Description
other The object to move construct from

Move constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
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>);

Parameters

Name Description
rhs The object to move construct from

Constructs the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(optional<U>&& rhs)
requires (detail::enable_from_other<T, U, U &&>);

Description

Converting move constructor.

Parameters

Name Description
rhs The object to move construct from

Constructs an empty optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(nullopt_t value) noexcept;

Parameters

Name Description
value The object to construct from

Constructs the value from u, forwarding it if necessary.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U = T>
constexpr
explicit(!std::is_convertible_v<U, T>)
optional(U&& u)
requires detail::enable_forward_value<T, U>;

Description

If u is convertible to T, this is an explicit constructor.

Constructs the contained value with u.

Parameters

Name Description
u The object to move construct from

Constructs the value in-place using the given arguments.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class... Args>
constexpr
explicit
optional(
    in_place_t,
    Args...&&... args)
requires std::is_constructible_v<T, Args...>;

Description

Constructs the contained value in-place using the given arguments.

Parameters

Name Description
args The arguments to use for in-place construction.

Constructs the value in-place using the given arguments.

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    class U,
    class... Args>
constexpr
explicit
optional(
    in_place_t,
    std::initializer_list<U> il,
    Args...&&... args)
requires std::is_constructible_v<T, std::initializer_list<U>&, Args&&...>;

Parameters

Name Description
il The initializer list to use for in-place construction.
args The arguments to use for in-place construction.

Destructors

Synopses

Declared in <beman/optional/optional.hpp>

Destructs the optional.

constexpr
~optional()
requires std::is_trivially_destructible_v<T> = default;
» more...

Destroys the optional and its value if it has one.

constexpr
~optional()
requires (!std::is_trivially_destructible_v<T>);
» more...

Destructs the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
~optional()
requires std::is_trivially_destructible_v<T> = default;

Destroys the optional and its value if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
~optional()
requires (!std::is_trivially_destructible_v<T>);

Assignment operators

Synopses

Declared in <beman/optional/optional.hpp>

Copy assigns the value from rhs if it has one.

constexpr
optional&
operator=(optional const& other)
requires std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T> &&
                     std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T> = default;
» more...

Copy assigns the value from rhs if it has one.

constexpr
optional<T>&
operator=(optional const& rhs)
requires std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T> &&
             (!std::is_trivially_copy_assignable_v<T>);
» more...

Assigns the contained value from rhs if it has one, destroying the old value if there

template<class U>
constexpr
optional<T>&
operator=(optional<U> const& rhs)
requires (detail::enable_assign_from_other<T, U, const U&>);
» more...

Move assigns the value from rhs if it has one.

constexpr
optional&
operator=(optional&& other)
requires std::is_move_constructible_v<T> && std::is_move_assignable_v<T> &&
                     std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T> = default;
» more...

Move assigns the value from rhs if it has one.

constexpr
optional<T>&
operator=(optional&& rhs) noexcept(std::is_nothrow_move_constructible_v<T>)
requires std::is_move_constructible_v<T> && std::is_move_assignable_v<T> &&
             (!std::is_trivially_move_assignable_v<T>);
» more...

Assigns the contained value from rhs if it has one, destroying the old value if there

template<class U>
constexpr
optional<T>&
operator=(optional<U>&& rhs)
requires (detail::enable_assign_from_other<T, U, U>);
» more...

Resets the optional to an empty state.

constexpr
optional<T>&
operator=(nullopt_t value) noexcept;
» more...

Assigns the contained value from u, destroying the old value if there

template<class U = T>
constexpr
optional<T>&
operator=(U&& u)
requires detail::enable_assign_forward<T, U>;
» more...

Return Value

optional&

Template Parameters

Name Description
U The type of the value to assign.

Parameters

Name Description
u The value to assign.

Copy assigns the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional&
operator=(optional const& other)
requires std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T> &&
                     std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T> = default;

Return Value

optional&

Parameters

Name Description
other The object to copy assign from

Copy assigns the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>&
operator=(optional const& rhs)
requires std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T> &&
             (!std::is_trivially_copy_assignable_v<T>);

Return Value

Reference to the current object

Parameters

Name Description
rhs The object to copy assign from

Assigns the contained value from rhs if it has one, destroying the old value if there

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U>
constexpr
optional<T>&
operator=(optional<U> const& rhs)
requires (detail::enable_assign_from_other<T, U, const U&>);

Description

Converting copy assignment operator.

Copies the value from rhs if there is one. Otherwise resets the contained value in *this.

Return Value

Reference to the current object

Parameters

Name Description
rhs The object to copy assign from

Move assigns the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional&
operator=(optional&& other)
requires std::is_move_constructible_v<T> && std::is_move_assignable_v<T> &&
                     std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T> = default;

Return Value

Reference to the current object

Parameters

Name Description
other The object to move assign from

Move assigns the value from rhs if it has one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>&
operator=(optional&& rhs) noexcept(std::is_nothrow_move_constructible_v<T>)
requires std::is_move_constructible_v<T> && std::is_move_assignable_v<T> &&
             (!std::is_trivially_move_assignable_v<T>);

Return Value

Reference to the current object

Parameters

Name Description
rhs The object to move assign from

Assigns the contained value from rhs if it has one, destroying the old value if there

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U>
constexpr
optional<T>&
operator=(optional<U>&& rhs)
requires (detail::enable_assign_from_other<T, U, U>);

Description

Converting move assignment operator.

Moves the value from rhs if there is one. Otherwise resets the contained value in *this.

Return Value

Reference to the current object

Parameters

Name Description
rhs The object to move assign from

Resets the optional to an empty state.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>&
operator=(nullopt_t value) noexcept;

Return Value

Reference to the current object

Parameters

Name Description
value The object to assign from

Assigns the contained value from u, destroying the old value if there

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U = T>
constexpr
optional<T>&
operator=(U&& u)
requires detail::enable_assign_forward<T, U>;

Description

Assigns the contained value from u, destroying the old value if there was one.

Return Value

optional&

Template Parameters

Name Description
U The type of the value to assign.

Parameters

Name Description
u The value to assign.

Applies a function to the contained value if there is one.

Synopses

Declared in <beman/optional/optional.hpp>

Applies a function to the contained value if there is one.

template<class F>
constexpr
auto
and_then(F&& f) &;
» more...

Applies a function to the contained value if there is one.

template<class F>
constexpr
auto
and_then(F&& f) &&;
» more...

Applies a function to the contained value if there is one.

template<class F>
constexpr
auto
and_then(F&& f) const &;
» more...

Applies a function to the contained value if there is one.

template<class F>
constexpr
auto
and_then(F&& f) const &&;
» more...

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
and_then(F&& f) &;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional. The function f must return an optional type.

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
and_then(F&& f) &&;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional. The function f must return an optional type.

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
and_then(F&& f) const &;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional. The function f must return an optional type.

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
and_then(F&& f) const &&;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional. The function f must return an optional type.

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

begin overloads

Synopses

Declared in <beman/optional/optional.hpp>

Returns an iterator to the beginning of the optional.

constexpr
optional<T>::iterator
begin() noexcept;
» more...

Returns a const iterator to the beginning of the optional.

constexpr
optional<T>::const_iterator
begin() const noexcept;
» more...

Return Value

Returns an iterator to the beginning of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>::iterator
begin() noexcept;

Return Value

iterator

Returns a const iterator to the beginning of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>::const_iterator
begin() const noexcept;

Return Value

const_iterator

emplace overloads

Synopses

Declared in <beman/optional/optional.hpp>

Constructs the value in-place, destroying the current one if there

template<class... Args>
constexpr
T&
emplace(Args...&&... args);
» more...

Constructs the value in-place using the given arguments, destroying the current one if there

template<
    class U,
    class... Args>
constexpr
T&
emplace(
    std::initializer_list<U> il,
    Args...&&... args);
» more...

Return Value

T&

Parameters

Name Description
args The argument list to use in emplacement construction.
il The initializer list to use in emplacement construction.

Constructs the value in-place, destroying the current one if there

Synopsis

Declared in <beman/optional/optional.hpp>
template<class... Args>
constexpr
T&
emplace(Args...&&... args);

Description

Constructs the value in-place, destroying the current one if there is one.

Return Value

T&

Parameters

Name Description
args The argument list to use in emplacement construction.

Constructs the value in-place using the given arguments, destroying the current one if there

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    class U,
    class... Args>
constexpr
T&
emplace(
    std::initializer_list<U> il,
    Args...&&... args);

Return Value

T&

Parameters

Name Description
il The initializer list to use in emplacement construction.
args The argument list to use in emplacement construction.

end overloads

Synopses

Declared in <beman/optional/optional.hpp>

Returns an iterator to the end of the optional.

constexpr
optional<T>::iterator
end() noexcept;
» more...

Returns a const iterator to the end of the optional.

constexpr
optional<T>::const_iterator
end() const noexcept;
» more...

Return Value

Returns an iterator to the end of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>::iterator
end() noexcept;

Return Value

iterator

Returns a const iterator to the end of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T>::const_iterator
end() const noexcept;

Return Value

const_iterator

Returns whether or not the optional has a value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
bool
has_value() const noexcept;

Description

Returns whether or not the optional has a value

Return Value

bool

Returns a reference to the contained value.

Synopses

Declared in <beman/optional/optional.hpp>

Returns a reference to the contained value.

constexpr
T&
operator*() &;
» more...

Returns a reference to the contained value.

constexpr
T const&
operator*() const &;
» more...

Returns a reference to the contained value.

constexpr
T&&
operator*() &&;
» more...

Return Value

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&
operator*() &;

Description

Returns the contained value

Return Value

T&

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T const&
operator*() const &;

Return Value

const T&

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&&
operator*() &&;

Return Value

T&&

Returns a pointer to the contained value.

Synopses

Declared in <beman/optional/optional.hpp>

Returns a pointer to the contained value.

constexpr
T const*
operator->() const;
» more...

Returns a pointer to the contained value.

constexpr
T*
operator->();
» more...

Return Value

T*

Returns a pointer to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T const*
operator->() const;

Description

Returns a pointer to the contained value

Return Value

a pointer to the contained value.

Returns a pointer to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T*
operator->();

Return Value

T*

or_else overloads

Synopses

Declared in <beman/optional/optional.hpp>

Returns an optional containing the contained value if it has one, or the result of applying f to the optional if it does not.

template<class F>
constexpr
optional<T>
or_else(F&& f) const &;
» more...

Returns an optional containing the contained value if it has one, or the result of calling f if it does not.

template<class F>
constexpr
optional<T>
or_else(F&& f) &&;
» more...

Return Value

Template Parameters

Name Description
F An invocable type returning an optional.

Parameters

Name Description
f The invocable to call if the optional is disengaged.

Returns an optional containing the contained value if it has one, or the result of applying f to the optional if it does not.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
optional<T>
or_else(F&& f) const &;

Return Value

Template Parameters

Name Description
F An invocable type returning an optional.

Parameters

Name Description
f The invocable to call if the optional is disengaged.

Returns an optional containing the contained value if it has one, or the result of calling f if it does not.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
optional<T>
or_else(F&& f) &&;

Return Value

Template Parameters

Name Description
F An invocable type returning an optional.

Parameters

Name Description
f The invocable to call if the optional is disengaged.

Resets the optional to an empty state, destroying the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
void
reset() noexcept;

Swaps this optional with the other.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
void
swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value && std::is_nothrow_swappable<T>::value);

Description

Swaps this optional with the other.

If neither optionals have a value, nothing happens. If both have a value, the values are swapped. If one has a value, it is moved to the other and the movee is left valueless.

Parameters

Name Description
rhs The optional to swap with.

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

Synopses

Declared in <beman/optional/optional.hpp>

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

template<class F>
constexpr
auto
transform(F&& f) &;
» more...

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

template<class F>
constexpr
auto
transform(F&& f) &&;
» more...

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

template<class F>
constexpr
auto
transform(F&& f) const &;
» more...

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

template<class F>
constexpr
auto
transform(F&& f) const &&;
» more...

Return Value

Parameters

Name Description
f An invocable to apply to the contained value.

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
transform(F&& f) &;

Description

Carries out some operation on the contained object if there is one.

Return Value

optional

Parameters

Name Description
f An invocable to apply to the contained value.

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
transform(F&& f) &&;

Return Value

auto

Parameters

Name Description
f An invocable to apply to the contained value.

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
transform(F&& f) const &;

Return Value

auto

Parameters

Name Description
f An invocable to apply to the contained value.

Returns an optional containing the result of applying f to the contained value, or an empty optional if there is no contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
transform(F&& f) const &&;

Return Value

auto

Parameters

Name Description
f An invocable to apply to the contained value.

Returns a reference to the contained value.

Synopses

Declared in <beman/optional/optional.hpp>

Returns a reference to the contained value.

constexpr
T&
value() &;
» more...

Returns a reference to the contained value.

constexpr
T const&
value() const &;
» more...

Returns a reference to the contained value.

constexpr
T&&
value() &&;
» more...

Return Value

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&
value() &;

Description

Returns the contained value if there is one, otherwise throws bad_optional_access

Return Value

T&

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T const&
value() const &;

Return Value

const T&

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&&
value() &&;

Return Value

T&&

Returns the contained value if there is one, otherwise returns u.

Synopses

Declared in <beman/optional/optional.hpp>

Returns the contained value if there is one, otherwise returns u.

template<class U = std::remove_cv_t<T>>
constexpr
T
value_or(U&& u) const &;
» more...

Returns the contained value if there is one, otherwise returns u.

template<class U = std::remove_cv_t<T>>
constexpr
T
value_or(U&& u) &&;
» more...

Return Value

T

Template Parameters

Name Description
U The type of the alternate value

Parameters

Name Description
u The value to return in the empty case

Returns the contained value if there is one, otherwise returns u.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U = std::remove_cv_t<T>>
constexpr
T
value_or(U&& u) const &;

Description

Returns the contained value if there is one, otherwise returns u

Return Value

T

Template Parameters

Name Description
U The type of the alternate value

Parameters

Name Description
u The value to return in the empty case

Returns the contained value if there is one, otherwise returns u.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U = std::remove_cv_t<T>>
constexpr
T
value_or(U&& u) &&;

Return Value

T

Template Parameters

Name Description
U The type of the alternate value

Parameters

Name Description
u The value to return in the empty case

Converts the optional to a boolean indicating whether it has a value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
explicit
operator bool() const noexcept;

Return Value

bool

The empty state of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
empty _ = {};

The contained value of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
T value_;

A specialization of optional for references.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
class optional<T&>;

Types

NameDescription
iterator The type of the iterator for the optional.
value_type The type of the value contained in the optional.

Member Functions

NameDescription
optional [constructor]Constructors
~optional [destructor]Destructor.
operator= Assignment operators
and_then Applies a function to the contained value if there is one.
begin Returns an iterator to the beginning of the optional.
emplace Emplaces a new value in the optional, destroying the current one if the optional is engaged.
end Returns an iterator to the end of the optional.
has_value Checks if the optional has a value.
operator* Returns a reference to the contained value.
operator-> Returns a pointer to the contained value.
or_else Calls a function if the optional is empty.
reset Resets the optional to an empty state.
swap Swaps the contents of this optional with another.
transform Applies a function to the contained value if there is one.
value Returns the contained value if there is one, otherwise throws
value_or Returns the contained value if there is one, otherwise returns u.
operator bool Converts the optional to a boolean value.

Friends

|===
Name Description
optional Optional Objects

The type of the iterator for the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
using iterator = /* implementation-defined */::contiguous_iterator<T, optional>;

The type of the value contained in the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
using value_type = T;

Constructors

Synopses

Declared in <beman/optional/optional.hpp>

Default constructor.

constexpr
optional() noexcept = default;
» more...

Copy constructor.

constexpr
optional(optional const& rhs) noexcept = default;
» more...

Constructs an empty optional.

constexpr
optional(nullopt_t value) noexcept;
» more...

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

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
explicit(!std::is_convertible_v<U &, T &>)
optional(optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T &, U &>);
» more...

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

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
explicit(!std::is_convertible_v<const U &, T &>)
optional(optional<U> const& rhs) noexcept(std::is_nothrow_constructible_v<T &, const U &>);
» more...

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
explicit(!std::is_convertible_v<U, T &>)
optional(U&& u) noexcept(std::is_nothrow_constructible_v<T &, U>);
» more...

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

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

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
explicit(!std::is_convertible_v<U, T &>)
optional(optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, U>));
» more...

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

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
explicit(!std::is_convertible_v<const U, T &>)
optional(optional<U> const&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, const U>));
» more...

In-place constructor.

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

Parameters

Name Description
u The value to construct from.
arg The value to construct in-place from.

Default constructor.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional() noexcept = default;

Copy constructor.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(optional const& rhs) noexcept = default;

Description

Constructs an empty optional if the rhs is empty, otherwise constructs the contained value from the rhs.

Parameters

Name Description
rhs The object to copy construct from

Constructs an empty optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional(nullopt_t value) noexcept;

Parameters

Name Description
value The object to construct from

Constructs an optional from another optional of type U

Synopsis

Declared in <beman/optional/optional.hpp>
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;

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Constructs an optional from another optional of type U.

Synopsis

Declared in <beman/optional/optional.hpp>
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
explicit(!std::is_convertible_v<U &, T &>)
optional(optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T &, U &>);

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Parameters

Name Description
rhs The optional to construct from.

Constructs an optional from another optional of type U

Synopsis

Declared in <beman/optional/optional.hpp>
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;

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Constructs an optional from another optional of type U.

Synopsis

Declared in <beman/optional/optional.hpp>
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
explicit(!std::is_convertible_v<const U &, T &>)
optional(optional<U> const& rhs) noexcept(std::is_nothrow_constructible_v<T &, const U &>);

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Parameters

Name Description
rhs The optional to construct from.

Construct from a U

Synopsis

Declared in <beman/optional/optional.hpp>
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
explicit(!std::is_convertible_v<U, T &>)
optional(U&& u) noexcept(std::is_nothrow_constructible_v<T &, U>);

Description

Constructs the contained value from u if it is convertible to T&. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Parameters

Name Description
u The value to construct from.

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

Synopsis

Declared in <beman/optional/optional.hpp>
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;

Parameters

Name Description
u The object to move construct from

Constructs an optional from another optional of type U

Synopsis

Declared in <beman/optional/optional.hpp>
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;

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Constructs an optional from another optional of type U.

Synopsis

Declared in <beman/optional/optional.hpp>
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
explicit(!std::is_convertible_v<U, T &>)
optional(optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, U>));

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Parameters

Name Description
rhs The optional to construct from.

Constructs an optional from another optional of type U

Synopsis

Declared in <beman/optional/optional.hpp>
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;

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Constructs an optional from another optional of type U.

Synopsis

Declared in <beman/optional/optional.hpp>
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
explicit(!std::is_convertible_v<const U, T &>)
optional(optional<U> const&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T &, const U>));

Description

Constructs the contained value from the rhs if it has a value, otherwise constructs an empty optional. If T& can be constructed from a temporary, this constructor is deleted to prevent binding a temporary to a reference.

Template Parameters

Name Description
U The type contained the right hand side optional.

Parameters

Name Description
rhs The optional to construct from.

In-place constructor.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class Arg>
requires (std::is_constructible_v<T&, Arg> && !detail::reference_constructs_from_temporary_v<T&, Arg>)
constexpr
explicit
optional(
    in_place_t,
    Arg&& arg);

Parameters

Name Description
arg The value to construct in-place from.

Destructor.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
~optional() = default;

Description

Does not destroy the contained value, as it is a reference.

Assignment operators

Synopses

Declared in <beman/optional/optional.hpp>

Assignment operator.

constexpr
optional&
operator=(optional const& rhs) noexcept = default;
» more...

Nullopt assignment operator.

constexpr
optional<T&>&
operator=(nullopt_t value) noexcept;
» more...

Return Value

optional&

Parameters

Name Description
rhs The value to assign.

Assignment operator.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional&
operator=(optional const& rhs) noexcept = default;

Description

If rhs has a value, assigns it to the contained value. Otherwise resets the contained value in *this.

Return Value

optional&

Parameters

Name Description
rhs The value to assign.

Nullopt assignment operator.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T&>&
operator=(nullopt_t value) noexcept;

Description

Destroys the current value if there is one, and leaves the optional in an empty state.

Return Value

optional&

Parameters

Name Description
value The object to assign from

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
auto
and_then(F&& f) const;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional. The function f must return an optional type.

Return Value

auto

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Returns an iterator to the beginning of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T&>::iterator
begin() const noexcept;

Return Value

iterator

Emplaces a new value in the optional, destroying the current one if the optional is engaged.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U>
requires (std::is_constructible_v<T&, U> && !detail::reference_constructs_from_temporary_v<T&, U>)
constexpr
T&
emplace(U&& u) noexcept(std::is_nothrow_constructible_v<T &, U>);

Description

Constructs the contained value from u if it is convertible to T&.

Return Value

T&

Template Parameters

Name Description
U The type of the value to emplace.

Parameters

Name Description
u The value to emplace.

Returns an iterator to the end of the optional.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
optional<T&>::iterator
end() const noexcept;

Return Value

iterator

Checks if the optional has a value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
bool
has_value() const noexcept;

Return Value

bool

Returns a reference to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&
operator*() const noexcept;

Return Value

T&

Returns a pointer to the contained value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T*
operator->() const noexcept;

Return Value

T*

Calls a function if the optional is empty.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
optional<T&>
or_else(F&& f) const;

Description

The return type is the same as the return type of f, which must return an optional type.

Return Value

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Resets the optional to an empty state.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
void
reset() noexcept;

Swaps the contents of this optional with another.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
void
swap(optional& rhs) noexcept;

Parameters

Name Description
rhs The value to swap with.

Applies a function to the contained value if there is one.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class F>
constexpr
optional<std::invoke_result_t<F, T&>>
transform(F&& f) const;

Description

The return type is the same as std::invoke_result_t<F, T&>, but wrapped in an optional.

Return Value

optional<std::invoke_result_t<F, T&>>

Template Parameters

Name Description
F The type of the invocable

Parameters

Name Description
f The invocable to apply to the contained value

Returns the contained value if there is one, otherwise throws

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
T&
value() const;

Return Value

T&

Returns the contained value if there is one, otherwise returns u.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class U = std::remove_cv_t<T>>
constexpr
std::remove_cv_t<T>
value_or(U&& u) const;

Return Value

std::remove_cv_t<T>

Template Parameters

Name Description
U The type of the alternate value

Parameters

Name Description
u The value to return in the empty case

Converts the optional to a boolean value.

Synopsis

Declared in <beman/optional/optional.hpp>
constexpr
explicit
operator bool() const noexcept;

Return Value

bool

Make an optional

Synopses

Declared in <beman/optional/optional.hpp>

Make an optional

template<
    int = 0,
    class T>
constexpr
optional<std::decay_t<T>>
make_optional(T&& t) noexcept(std::is_nothrow_constructible_v<optional<std::decay_t<T>>, T>)
requires std::is_constructible_v<std::decay_t<T>, T>;
» more...
template<
    typename T,
    typename... Args>
constexpr
optional<T>
make_optional(Args...&&... args) noexcept(std::is_nothrow_constructible_v<T, Args...>)
requires std::is_constructible_v<T, Args...>;
» more...
template<
    typename T,
    typename U,
    typename... Args>
constexpr
optional<T>
make_optional(
    std::initializer_list<U> il,
    Args...&&... args) noexcept(std::is_nothrow_constructible_v<T, std::initializer_list<U> &, Args...>)
requires std::is_constructible_v<T, std::initializer_list<U>&, Args...>;
» more...

Make an optional

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    int = 0,
    class T>
constexpr
optional<std::decay_t<T>>
make_optional(T&& t) noexcept(std::is_nothrow_constructible_v<optional<std::decay_t<T>>, T>)
requires std::is_constructible_v<std::decay_t<T>, T>;

Return Value

Optional Objects

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename... Args>
constexpr
optional<T>
make_optional(Args...&&... args) noexcept(std::is_nothrow_constructible_v<T, Args...>)
requires std::is_constructible_v<T, Args...>;

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U,
    typename... Args>
constexpr
optional<T>
make_optional(
    std::initializer_list<U> il,
    Args...&&... args) noexcept(std::is_nothrow_constructible_v<T, std::initializer_list<U> &, Args...>)
requires std::is_constructible_v<T, std::initializer_list<U>&, Args...>;

Swap

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
constexpr
void
swap(
    optional<T>& x,
    optional<T>& y) noexcept(noexcept(lhs.swap(rhs)))
requires std::is_move_constructible_v<T> && std::is_swappable_v<T>;

Parameters

Name Description
x Optional Objects
y Optional Objects

Equality operators

Synopses

Declared in <beman/optional/optional.hpp>

Equality operator

template<
    typename T,
    typename U>
constexpr
bool
operator==(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_eq_rel<T, U>;
» more...

Equality operator

template<class T>
constexpr
bool
operator==(
    optional<T> const& lhs,
    nullopt_t rhs) noexcept;
» more...

Equality operator

template<
    typename T,
    typename U>
constexpr
bool
operator==(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_eq_rel<T, U>;
» more...

Equality operator

template<
    typename T,
    typename U>
constexpr
bool
operator==(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_eq_rel<T, U>;
» more...

Equality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator==(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_eq_rel<T, U>;

Return Value

true if the objects are equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Equality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
constexpr
bool
operator==(
    optional<T> const& lhs,
    nullopt_t rhs) noexcept;

Return Value

true if the objects are equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Equality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator==(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_eq_rel<T, U>;

Return Value

true if the objects are equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Equality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator==(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_eq_rel<T, U>;

Return Value

true if the objects are equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Inequality operators

Synopses

Declared in <beman/optional/optional.hpp>

Inequality operator

template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_ne_rel<T, U>;
» more...

Inequality operator

template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_ne_rel<T, U>;
» more...

Inequality operator

template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_ne_rel<T, U>;
» more...

Inequality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_ne_rel<T, U>;

Return Value

true if the objects are not equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Inequality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_ne_rel<T, U>;

Return Value

true if the objects are not equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Inequality operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator!=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_ne_rel<T, U>;

Return Value

true if the objects are not equal, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than operators

Synopses

Declared in <beman/optional/optional.hpp>

Less-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator<(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_lt_rel<T, U>;
» more...

Less-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator<(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_lt_rel<T, U>;
» more...

Less-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator<(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_lt_rel<T, U>;
» more...

Less-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_lt_rel<T, U>;

Return Value

true if the left object is less than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_lt_rel<T, U>;

Return Value

true if the left object is less than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_lt_rel<T, U>;

Return Value

true if the left object is less than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than-or-equal operators

Synopses

Declared in <beman/optional/optional.hpp>

Less-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_le_rel<T, U>;
» more...

Less-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_le_rel<T, U>;
» more...

Less-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_le_rel<T, U>;
» more...

Less-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_le_rel<T, U>;

Return Value

true if the left object is less than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_le_rel<T, U>;

Return Value

true if the left object is less than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Less-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator<=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_le_rel<T, U>;

Return Value

true if the left object is less than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than operators

Synopses

Declared in <beman/optional/optional.hpp>

Greater-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator>(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_gt_rel<T, U>;
» more...

Greater-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator>(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_gt_rel<T, U>;
» more...

Greater-than operator

template<
    typename T,
    typename U>
constexpr
bool
operator>(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_gt_rel<T, U>;
» more...

Greater-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_gt_rel<T, U>;

Return Value

true if the left object is greater than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_gt_rel<T, U>;

Return Value

true if the left object is greater than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_gt_rel<T, U>;

Return Value

true if the left object is greater than the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than-or-equal operators

Synopses

Declared in <beman/optional/optional.hpp>

Greater-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_ge_rel<T, U>;
» more...

Greater-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_ge_rel<T, U>;
» more...

Greater-than-or-equal operator

template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_ge_rel<T, U>;
» more...

Greater-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    optional<T> const& lhs,
    optional<U> const& rhs)
requires detail::optional_ge_rel<T, U>;

Return Value

true if the left object is greater than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    optional<T> const& lhs,
    U const& rhs)
requires detail::optional_ge_rel<T, U>;

Return Value

true if the left object is greater than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Greater-than-or-equal operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
constexpr
bool
operator>=(
    T const& lhs,
    optional<U> const& rhs)
requires detail::optional_ge_rel<T, U>;

Return Value

true if the left object is greater than or equal to the right object, false otherwise

Parameters

Name Description
lhs The left operand
rhs The right operand

Three-way comparison operators

Synopses

Declared in <beman/optional/optional.hpp>

Three-way comparison operator

template<
    typename T,
    std::three_way_comparable_with<T> U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& x,
    optional<U> const& y);
» more...

Three-way comparison operator

template<class T>
constexpr
std::strong_ordering
operator<=>(
    optional<T> const& x,
    nullopt_t rhs) noexcept;
» more...

Three-way comparison operator

template<
    typename T,
    typename U>
requires (!is_derived_from_optional<U>) && std::three_way_comparable_with<T, U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& x,
    U const& v);
» more...

Three-way comparison operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    std::three_way_comparable_with<T> U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& x,
    optional<U> const& y);

Return Value

The relative order of the objects

Parameters

Name Description
x The left operand
y The right operand

Three-way comparison operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
constexpr
std::strong_ordering
operator<=>(
    optional<T> const& x,
    nullopt_t rhs) noexcept;

Return Value

The relative order of the objects

Parameters

Name Description
x The left operand
rhs The right operand

Three-way comparison operator

Synopsis

Declared in <beman/optional/optional.hpp>
template<
    typename T,
    typename U>
requires (!is_derived_from_optional<U>) && std::three_way_comparable_with<T, U>
constexpr
std::compare_three_way_result_t<T, U>
operator<=>(
    optional<T> const& x,
    U const& v);

Return Value

The relative order of the objects

Parameters

Name Description
x The left operand
v The right operand

Tag for in-place construction

Synopsis

Declared in <beman/optional/optional.hpp>
inline constexpr in_place_t in_place = in_place{};

Tag to disengage optional objects.

Synopsis

Declared in <beman/optional/optional.hpp>
inline constexpr nullopt_t nullopt = nullopt{nullopt_t::Tag::tag};

Concept for checking if derived from optional.

Synopsis

Declared in <beman/optional/optional.hpp>
template<class T>
concept is_derived_from_optional = requires(const T& t) { // exposition only
    []<class U>(const optional<U>&) {}(t);
};

Created with MrDocs