diff options
| author | Aiden Woodruff <aiden@aidenw.net> | 2024-12-12 12:49:24 -0500 |
|---|---|---|
| committer | Aiden Woodruff <aiden@aidenw.net> | 2024-12-12 12:49:24 -0500 |
| commit | 96765e7ffa68f5fc6131073a8a2b50372e3f727f (patch) | |
| tree | f8143fe68eb76f94d0d6cfa20de2a4f97b4a32c7 | |
| parent | b7ce17592113b80a7eace023325b6e24891e22f1 (diff) | |
| download | wcards-96765e7ffa68f5fc6131073a8a2b50372e3f727f.tar.gz wcards-96765e7ffa68f5fc6131073a8a2b50372e3f727f.tar.bz2 wcards-96765e7ffa68f5fc6131073a8a2b50372e3f727f.zip | |
add ordering operator to wcards::Card
- card.h (Card::operator<): new function.
- (Card::operator==): make const.
Signed-off-by: Aiden Woodruff <aiden@aidenw.net>
| -rw-r--r-- | card.h | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -24,9 +24,12 @@ namespace wcards { | |||
| 24 | if (ranks.find(str[1]) != std::string::npos) | 24 | if (ranks.find(str[1]) != std::string::npos) |
| 25 | value += ranks.find(str[1]) + 1; | 25 | value += ranks.find(str[1]) + 1; |
| 26 | } | 26 | } |
| 27 | bool operator==(const Card& rhs) { | 27 | bool operator==(const Card& rhs) const noexcept { |
| 28 | return value == rhs.value; | 28 | return value == rhs.value; |
| 29 | } | 29 | } |
| 30 | bool operator<(const Card& rhs) const noexcept { | ||
| 31 | return value < rhs.value; | ||
| 32 | } | ||
| 30 | operator bool(void) const noexcept { | 33 | operator bool(void) const noexcept { |
| 31 | return value != 0; | 34 | return value != 0; |
| 32 | } | 35 | } |
