二元谓词中添加const的问题(未解决)

#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");

}

  

转载于:https://www.cnblogs.com/xiaochige/p/6930670.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值