diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-03-22 21:49:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-03-22 23:51:00 +0100 |
| commit | 2fca6ad9716429660e7162807582db00c3ca6865 (patch) | |
| tree | 37bc7a343a6d72b19311ebe7dbb4f07c185491dc /src | |
| parent | 5ddb909ac7033d4becffa39dadbb14b8ab4ca0ab (diff) | |
Add operator< for Fraction.
Diffstat (limited to 'src')
| -rw-r--r-- | src/types.cc | 9 | ||||
| -rw-r--r-- | src/types.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/types.cc b/src/types.cc index bbb66e3a..3b79be2a 100644 --- a/src/types.cc +++ b/src/types.cc @@ -110,6 +110,15 @@ dcp::operator!= (Fraction const & a, Fraction const & b) } +bool +dcp::operator< (Fraction const& a, Fraction const& b) +{ + DCP_ASSERT(a.denominator > 0); + DCP_ASSERT(b.denominator > 0); + return a.numerator * b.denominator < b.numerator * a.denominator; +} + + Colour::Colour (int r_, int g_, int b_) : r (r_) , g (g_) diff --git a/src/types.h b/src/types.h index e0b1f064..91363beb 100644 --- a/src/types.h +++ b/src/types.h @@ -176,6 +176,7 @@ public: extern bool operator== (Fraction const & a, Fraction const & b); extern bool operator!= (Fraction const & a, Fraction const & b); +extern bool operator< (Fraction const& a, Fraction const& b); enum class NoteType { |
