为包含指针的关联容器指定比较类型
2016-08-02 09:50
429 查看
#include <iostream> #include <string> #include <algorithm> #include <iterator> #include <set> using namespace std; class DereferenceLess { public: template<typename T> bool operator()(const T* ptr1,const T* ptr2) { return *ptr1<*ptr2; } }; class Deference{ public: template<typename T> const T& operator()(const T* ptr) { return *ptr; } }; int main() { set<string*,DereferenceLess> ssp; ssp.insert(new string("Anteater")); ssp.insert(new string("Wombat")); ssp.insert(new string("Lemur")); ssp.insert(new string("Penguin")); transform(ssp.begin(),ssp.end(),ostream_iterator<string>(cout,"\n"),Deference()); return 0; }
相关文章推荐
- effective stl: 第20条,为包含指针的关联容器指定比较类型
- 为包含指针的关联容器指定比较类型
- Effective STL 为包含指针的关联容器指定比较类型
- Effective STL 为包含指针的关联容器指定比较类型
- Effective STL 为包含指针的关联容器指定比较类型
- 为包含指针的关联容器指定比较类型
- 为指针的关联容器指定比较类型
- 条款20:为指针的关联容器指定比较类型
- 为指针的关联容器指定比较类型
- 条款20:为指针的关联容器指定比较类型——effective STL
- 使用STL的经验总结_指定关联容器的比较类型_12
- Effective STL - 为指针的关联容器指定比较函数
- 关联容器存放的是指针时,自定义比较函数模板
- Java读取文件夹下的指定类型的文件(包含子文件夹)
- BOOL,int,float,指针类型的变量a 与“零”的比较语句
- Effective STL 条款21: 关联容器的strict weak order(让比较函数对相等的值返回false) .
- 关联容器的比较函数的一点认识
- Effective STL 条款21: 关联容器的strict weak order(让比较函数对相等的值返回false)
- C++-关联容器类型map
- 使用回调函数的方式 删除包含子文件夹及文件的 文件夹,删除文件夹内指定类型的文件