【发布时间】:2011-04-12 06:50:03
【问题描述】:
您好,我有一些用于 std::list 的重载运算符。
我将对存储在一个列表中,由一个 int 值和一个位置数组组成:
typedef std::pair< int, std::vector<int,3> > pointPairType;
typedef std::list< pointPairType > pointListQueueType;
pointListQueueType pointsQueue;
// adding some points to the list
我想根据对的第一个值对列表进行排序, 我虽然这会工作:
创建一个比较类,
并用它提供短算法:
// comparison function
template < class T1, class T2 >
class compareFirst
{
public:
bool operator() (const std::pair<T1,T2>& l, const std::pair<T1,T2>& r)
{
return l.first < r.first;
}
};
... 主要是:
// use of sorting algorithm : error here
pointsQueue.sort(< int, std::vector<int,3> >compareFirst);
但我在'
任何帮助将不胜感激! 谢谢!
【问题讨论】: