Skip to content

Commit a920d99

Browse files
committed
Fix AVCPP_USE_SPACESHIP_OPERATOR usage
1 parent 91d2868 commit a920d99

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/rational.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "ffmpeg.h"
99
#include "avutils.h"
1010

11-
#ifdef AVCPP_USE_SPACESHIP_OPERATOR
11+
#if AVCPP_USE_SPACESHIP_OPERATOR
1212
# include <compare>
1313
#endif
1414

@@ -51,18 +51,16 @@ class Rational
5151
Rational& operator= (double value) noexcept;
5252

5353
bool operator== (const Rational &other) const noexcept;
54-
#ifdef AVCPP_USE_SPACESHIP_OPERATOR
54+
#if AVCPP_USE_SPACESHIP_OPERATOR
5555
std::strong_ordering operator<=>(const Rational &other) const noexcept
5656
{
57-
switch (threewaycmp(other)) {
58-
case -1:
59-
return std::strong_ordering::less;
60-
case 0:
57+
if (auto const cmp = threewaycmp(other); cmp == 0) {
6158
return std::strong_ordering::equal;
62-
case 1:
59+
} else if (cmp < 0) {
60+
return std::strong_ordering::less;
61+
} else {
6362
return std::strong_ordering::greater;
6463
}
65-
return std::strong_ordering::equal; // make a compiler happy
6664
}
6765
#else
6866
bool operator!= (const Rational &other) const noexcept {

0 commit comments

Comments
 (0)