经过长时间的学习终于可以开始tinystl的仿(chao)写工作了,本文参考了这位大佬的github,坦白讲我只是补充了注释,因为tinystl的代码真的非常经典而我又没什么这种大型项目的经验,所以只能这样做,不过相信能够有助于大家的学习
#强烈建议按顺序阅读本专栏
functional是非常简单的一个类,提供了小于和相等两个函数供调用
#pragma once
#ifndef _FUNCTIONAL_H_
#define _FUNCTIONAL_H_
namespace mySTL {
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;
}
};
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 // ! _FUNCTIONSL_H_