Skip to content

Instantly share code, notes, and snippets.

@zjplab
Created January 10, 2020 21:35
Show Gist options
  • Save zjplab/0c09f3703d5d79987616beed0fe52ccd to your computer and use it in GitHub Desktop.
Save zjplab/0c09f3703d5d79987616beed0fe52ccd to your computer and use it in GitHub Desktop.
C++ Comparator(Custom comparison ops)
struct cmpByStringLength {
bool operator()(const std::string& a, const std::string& b) const {
return a.length() < b.length();
}
};
// ...
std::map<std::string, std::string, cmpByStringLength> myMap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment