Skip to content

Commit

Permalink
[#9] refactor: if
Browse files Browse the repository at this point in the history
  • Loading branch information
kogetsu7 committed Jan 5, 2025
1 parent 50e96a6 commit eb879ea
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions other/choose_min_max.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
* @brief Choose Minimum
*/
template <class T> bool chmin(T& a, const T& b) {
return (a > b) ? (a = b, true) : false;
if (a > b) {
a = b;
return true;
}

return false;
}

/**
* @brief Choose Maximum
*/
template <class T> bool chmax(T& a, const T& b) {
return (a < b) ? (a = b, true) : false;
if (a < b) {
a = b;
return true;
}

return false;
}

0 comments on commit eb879ea

Please sign in to comment.