From 6abd3d57f666ce1cd4c4c792e649fd313bee22ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2016 11:03:57 +0200 Subject: Add case_compare_string, case_compare_c_string comparators --- butl/utility | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/butl/utility b/butl/utility index e2e9b37..cedfc3d 100644 --- a/butl/utility +++ b/butl/utility @@ -60,6 +60,24 @@ namespace butl int casecmp (const char*, const char*, std::size_t = std::string::npos); + // Case-insensitive key comparators (i.e., to be used in sets, maps, etc). + // + struct case_compare_string + { + bool operator() (const std::string& x, const std::string& y) const + { + return casecmp (x, y) < 0; + } + }; + + struct case_compare_c_string + { + bool operator() (const char* x, const char* y) const + { + return casecmp (x, y) < 0; + } + }; + bool alpha (char); -- cgit v1.1