#include <iostream>
using namespace std;
#include"set"
#include"algorithm"
struct compareNoCase
{
//bool operator()(const string &str1, const string &str2) 这种居然是错误的。不知道为什么
bool operator()(const string &str1, const string &str2) const
{
string str11;
str11.resize( str1.size ());
transform(str1.begin(), str1.end(), str11.begin(), tolower);
string str22;
str22.resize ( str2.size());
transform(str2.begin(), str2.end(), str22.begin(), tolower);
return (str11 > str22);
}
};
void main01()
{
set<string > s1;
s1.insert("aaa");
s1.insert("wew");
s1.insert("qwe");
set<string>::iterator it = s1.find("aaa");
if (it == s1.end())
{
cout << "没有找到" << endl;
}
else
cout << "找到" << endl;
set<string, compareNoCase> s2;
s2.insert("aAa");
s2.insert("wSw");
s2.insert("qAe");
set<string, compareNoCase>::iterator it2 = s2.find("aAa");
if (it2 == s2.end())
{
cout << "没有找到" << endl;
}
else
cout << "找到" << endl;
}
int main()
{
main01();
system("pause");
}