Skip to content

Commit

Permalink
karm-base: Use <=> in Distinct.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Apr 16, 2024
1 parent f24f9e7 commit 355bdb6
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions src/libs/karm-base/distinct.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <compare>

namespace Karm {

template <typename T, typename TAG>
Expand All @@ -12,29 +14,9 @@ struct Distinct {

constexpr T value() const { return _value; }

constexpr bool operator==(Distinct<T, TAG> other) const {
return _value == other._value;
}

constexpr bool operator!=(Distinct<T, TAG> other) const {
return _value != other._value;
}

constexpr bool operator<(Distinct<T, TAG> other) const {
return _value < other._value;
}
constexpr bool operator==(Distinct<T, TAG> const &other) const = default;

constexpr bool operator>(Distinct<T, TAG> other) const {
return _value > other._value;
}

constexpr bool operator<=(Distinct<T, TAG> other) const {
return _value <= other._value;
}

constexpr bool operator>=(Distinct<T, TAG> other) const {
return _value >= other._value;
}
constexpr auto operator<=>(Distinct<T, TAG> const &other) const = default;

constexpr Distinct<T, TAG> operator+(Distinct<T, TAG> other) const {
return Distinct<T, TAG>(_value + other._value);
Expand Down

0 comments on commit 355bdb6

Please sign in to comment.