https://blog.csdn.net/renyican/article/details/50058011
使用示例:
#include <iostream> // std::cout
#include <functional> // std::less
#include <algorithm> // std::sort, std::includes
int main(void)
{
int foo[]={10,20,5,15,25};
std::sort (foo, foo+5, std::less<int>()); // 5 10 15 20 25
for(int i = 0; i< 5; i++)
{
std::cout << "value:"<<foo[i]<<std::endl;
}
return 0;
}
结果输出:
c++11定义如下:
template <class T> struct less {
bool operator() (const T& x, const T& y) const {return x<y;}
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
---------------------
作者:renyican
来源:CSDN
原文:https://blog.csdn.net/renyican/article/details/50058011
版权声明:本文为博主原创文章,转载请附上博文链接!