beman::optional::operator==

Equality operators

Synopses

Declared in <beman/optional/optional.hpp>

Compares two nullopt_t objects for equality.

constexpr
bool
operator==(
    nullopt_t lhs,
    nullopt_t rhs) noexcept;
» more...

Compares two optionals for equality.

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

Compares an optional against nullopt.

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

Compares an engaged optional's value against a value for equality.

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

Compares a value against an engaged optional's value for equality.

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

Return Value

  • Always true, since all nullopt_t objects compare equal.
  • true if both are disengaged, or both are engaged and their contained values are equal.
  • true if lhs is disengaged.
  • true if lhs is engaged and its contained value equals rhs.
  • true if rhs is engaged and lhs equals its contained value.

Parameters

NameDescription
lhsThe left-hand nullopt_t object.
rhsThe right-hand nullopt_t object.