Created
January 10, 2020 21:35
-
-
Save zjplab/0c09f3703d5d79987616beed0fe52ccd to your computer and use it in GitHub Desktop.
C++ Comparator(Custom comparison ops)
This file contains 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
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