首页 > 其他 > 详细

std::set自定义比较函数

时间:2015-01-04 21:21:14      阅读:380      评论:0      收藏:0      [点我收藏+]
#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自定义比较函数

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!