Skip to content

Commit

Permalink
evaluator: Fixed boolean compare warning
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 10, 2025
1 parent da45d0c commit bc00279
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/source/pl/core/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,26 @@ namespace pl::core {
}
},
[](pl::integral auto lhs, pl::floating_point auto rhs) -> std::strong_ordering {
if (lhs == rhs) return std::strong_ordering::equal;
if (lhs < rhs) return std::strong_ordering::less;
return std::strong_ordering::greater;
if constexpr (std::same_as<decltype(lhs), char> || std::same_as<decltype(rhs), char>)
return char(lhs) <=> char(rhs);
else if constexpr (std::same_as<decltype(lhs), bool> || std::same_as<decltype(rhs), bool>)
return bool(lhs) <=> bool(rhs);
else {
if (lhs == rhs) return std::strong_ordering::equal;
if (lhs < rhs) return std::strong_ordering::less;
return std::strong_ordering::greater;
}
},
[](pl::floating_point auto lhs, pl::integral auto rhs) -> std::strong_ordering {
if (lhs == rhs) return std::strong_ordering::equal;
if (lhs < rhs) return std::strong_ordering::less;
return std::strong_ordering::greater;
if constexpr (std::same_as<decltype(lhs), char> || std::same_as<decltype(rhs), char>)
return char(lhs) <=> char(rhs);
else if constexpr (std::same_as<decltype(lhs), bool> || std::same_as<decltype(rhs), bool>)
return bool(lhs) <=> bool(rhs);
else {
if (lhs == rhs) return std::strong_ordering::equal;
if (lhs < rhs) return std::strong_ordering::less;
return std::strong_ordering::greater;
}
},
[](auto, auto) -> std::strong_ordering {
return std::strong_ordering::less;
Expand Down

0 comments on commit bc00279

Please sign in to comment.