Skip to content

Instantly share code, notes, and snippets.

@milesrout
Last active May 29, 2016 05:22
Show Gist options
  • Save milesrout/a57d2585f5637abb177f to your computer and use it in GitHub Desktop.
Save milesrout/a57d2585f5637abb177f to your computer and use it in GitHub Desktop.
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;
}
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;
}
#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;
}
#[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