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;

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>;

Compares an optional against nullopt.

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

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>;

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>;

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

Name

Description

lhs

The left‐hand nullopt_t object.

rhs

The right‐hand nullopt_t object.

Created with MrDocs