我对 std::sort 算法有疑问。这是我的测试代码:
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
是否可以在不使用任何独立函数或仿函数的情况下对变量上的向量进行排序?另外,请注意我没有使用 boost。