No operators for the char_traits, only static member functions. Best idea is to take most from char_traits:
That's it.Code:template<typename C> struct ic_char_traits : public char_traits<C> { static int compare(const char_type *s1, const char_type *s2, size_t num) { int i=0; for(;i<num;++i) { if(!eq(*s1, *s2)) { if(lt(*s1, *s2)) { return -1; } else { return 1; } } } return 0; } static bool eq(const char_type &ch1, const char_type &ch2) { locale loc; return tolower(ch1, loc) == tolower(ch2, loc); } static bool eq_int_type(const int_type &ch1, const int_type &ch2) { locale loc; return tolower((char_type)ch1, loc) == tolower((char_type)ch2, loc); } struct eq_pred { bool operator()(C ch1, C ch2) { locale loc; return tolower(ch1, loc) == tolower(ch2, loc); } }; static const char_type * find(const char_type *s, size_t num, const char_type &c) { const char_type *res = search_n(s, s+num, 1, c); return (res < s+num)?res:NULL; } static bool lt(const char_type &ch1, const char_type &ch2) { locale loc; return char_traits<char_type>::lt(tolower(ch1, loc), tolower(ch2, loc)); } };




CornedBee
Reply With Quote