//: C01:ichar_traits.h // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Creating your own character traits #ifndef ICHAR_TRAITS_H #define ICHAR_TRAITS_H #include #include struct ichar_traits : std::char_traits { // We'll only change character by // character comparison functions static bool eq(char c1st, char c2nd) { return std::toupper(c1st) == std::toupper(c2nd); } static bool ne(char c1st, char c2nd) { return std::toupper(c1st) != std::toupper(c2nd); } static bool lt(char c1st, char c2nd) { return std::toupper(c1st) < std::toupper(c2nd); } static int compare(const char* str1, const char* str2, size_t n) { for(int i = 0; i < n; i++) { if(std::tolower(*str1)>std::tolower(*str2)) return 1; if(std::tolower(*str1) 0 && std::toupper(*s1) != std::toupper(c)) s1++; return s1; } }; #endif // ICHAR_TRAITS_H ///:~