我有一个关于std :: sort算法的问题。这里是我的测试代码:std ::排序没有函子
struct MyTest
{
int m_first;
int m_second;
MyTest(int first = 0, int second = 0) : m_first(first), m_second(second)
{
}
};
int main(int argc,char *argv[])
{
std::vector<MyTest> myVec;
for(int i = 0; i < 10; ++i)
{
myVec.push_back(MyTest(i, i + 1));
}
//Sort the vector in descending order on m_first without using stand alone function or functors
return 0;
}
是否有可能在可变m_first
矢量进行排序,而无需使用任何独立的函数或仿函数?另外,请注意,我没有使用提升。
操作员应该只带一个参数并与“this”进行比较。 – sth 2009-06-01 07:58:02
是的,修好了,谢谢! – 2009-06-01 08:03:29