I am using std::string\'s find() method to test if a string is a substring of another. Now I need case insensitive version of the same thing. For s
#include
using namespace std;
template
struct ichar {
operator charT() const { return toupper(x); }
charT x;
};
template
static basic_string > *istring(basic_string &s) { return (basic_string > *)&s; }
template
static ichar *istring(const charT *s) { return (ichar *)s; }
int main()
{
string s = "The STRING";
wstring ws = L"The WSTRING";
cout << istring(s)->find(istring("str")) << " " << istring(ws)->find(istring(L"wstr")) << endl;
}
A little bit dirty, but short & fast.