码迷,mamicode.com
首页 > 其他好文 > 详细

std::set自定义比较函数

时间:2015-01-04 21:24:32      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:stdset自定义比较函数

#include <set>
struct A
{
	int i;
	int j;
	bool operator<(A const &ref)const
	{
		return i < ref.i;
	}
	bool operator==(A const &ref)const
	{
		return i == ref.i && j == ref.j;
	}
};
int main()
{
	A val1 = {1, 2};
	A val2 = {2, 2};
	std::set<A> my_set;
	my_set.insert(val1);
	my_set.insert(val2);
}

std::set自定义比较函数

标签:stdset自定义比较函数

原文地址:http://blog.csdn.net/cjc211322/article/details/42400293

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!