Three‐way comparison operators

Synopses

Declared in <mp‐units/utility/safe_int.h>

Compares a safe_int with a constrained value

[[nodiscard]]
constexpr
auto
operator<=>(
    safe_int lhs,
    constrained<U, CP> const& rhs);

Compares a safe_int with a floating‐point value.

[[nodiscard]]
constexpr
auto
operator<=>(
    safe_int lhs,
    U rhs);

Compares a safe_int with an integral scalar, comparing safely across signedness.

[[nodiscard]]
constexpr
std::strong_ordering
operator<=>(
    safe_int lhs,
    U rhs);

Compares two safe_int values by their wrapped underlying values.

[[nodiscard]]
constexpr
std::strong_ordering
operator<=>(
    safe_int lhs,
    safe_int rhs) noexcept;

Return Value

  • the ordering of the underlying values

  • the ordering between the wrapped value and rhs

  • the ordering of the wrapped values

Note

The return value should not be discarded.

Template Parameters

Name

Description

U

a floating‐point‐like type (treat_as_floating_point<U> is true)

Parameters

Name

Description

lhs

the safe_int to compare

rhs

the constrained value to compare against

Created with MrDocs