You are looking at it from the wrong angle...Originally posted by kedaman
hmm, this is the second time I think STL isn't generic enough
A couple more operators are needed, of course, but you get the idea. Then you just use ci_char instead of char in std::string... you get case insensitive comparisons, but you also conserve case when copying.Code:#define lcase(x) (((x >='A') && (x <= 'Z')) ? x-'A' + 'a' : x) template<class t=char> class ci_char { private: t m_c; public: ci_char& operator =(t c){m_c = c;} bool operator ==(t& c) { return lcase(m_c)==lcase(c); } bool operator ==(ci_char& c){ return lcase(m_c)==lcase(c.m_c);} ... };
Z.




Reply With Quote