Last active
May 29, 2016 05:22
-
-
Save milesrout/a57d2585f5637abb177f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool operator<(const Version& other) { | |
if (major < other.major) | |
return true; | |
if (minor < other.minor) | |
return true; | |
if (revision < other.revision) | |
return true; | |
if (build < other.build) | |
return true; | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool operator<(const Version& other) { | |
if (major != other.major) | |
return (major < other.major); | |
if (minor != other.minor) | |
return (minor < other.minor); | |
if (revision != other.revision) | |
return (revision < other.revision); | |
if (build != other.build) | |
return (build < other.build); | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define o(x) \ | |
if (x != other.x) return (x < other.x) | |
bool operator<(const Version& other) { | |
o(major); | |
o(minor); | |
o(revision); | |
o(build); | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Ord)] | |
struct Version { | |
major: i32, | |
minor: i32, | |
revision: i32, | |
build: i32 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment