工具:visual studio 2019
在sort中用到了functional中函数,默认排序从小到大, 这是是非常简单的一个类,提供了小于和相等两个函数供调用,可以直接放上代码,直接明了的
/*
* functional是非常简单的一个类,提供了小于和相等两个函数供调用
*
*/
#ifndef _FUNCTIONAL_H_
#define _FUNCTIONAL_H_
namespace mySTL{
//********** [less] ****************
template<class T>
struct less{
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
result_type operator()(const first_argument_type& x, const second_argument_type& y){
return x < y;
}
};
//********** [equal_to] ****************
template<class T>
struct equal_to{
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
result_type operator()(const first_argument_type& x, const second_argument_type& y){
return x == y;
}
};
}
#endif