使用std::set作为用户自定义类型的…
2015-10-10 09:19
225 查看
先看看std::set的声明
template < class Key, class
Traits=less<Key>, class
Allocator=allocator<Key>
> class set
对比下std::map的
template <class Key, class
Type, class Traits = less<Key>,
class Allocator=allocator<pair <const
Key, Type> > > class
map
可以猜出,在std::set中使用用户自定义类型和使用自定义类型作为std::map的key没啥区别——可以作为std::map的key的用户自定义类型,就可以作为std::set的元素,反之亦然。故可以直接参考前几天写的《使用用户自定义类型作为std::map的key》
template < class Key, class
Traits=less<Key>, class
Allocator=allocator<Key>
> class set
对比下std::map的
template <class Key, class
Type, class Traits = less<Key>,
class Allocator=allocator<pair <const
Key, Type> > > class
map
可以猜出,在std::set中使用用户自定义类型和使用自定义类型作为std::map的key没啥区别——可以作为std::map的key的用户自定义类型,就可以作为std::set的元素,反之亦然。故可以直接参考前几天写的《使用用户自定义类型作为std::map的key》
相关文章推荐
- 多线程程序中死锁的分析和解决方案
- 项目1-发布一篇博文
- 使用boost::filesystem实现目录遍…
- perl输出环境变量
- python 面向对象编程案例01
- 深入理解Java Proxy
- php中new一个类对象的两种写法
- 使用用户自定义类型作为std::map的…
- 为何编译器无法自动生成拷贝函数
- 史上最简单的c++四种cast使用教程
- 项目管理之进度悖论
- 使用boost::asio::write时慎用Comp…
- 使用boost条件变量实现消息队列
- 并行计算:近来语言发展的趋势和我…
- 转载:C, Erlang, Java and Go Web…
- c++中实现类似java printStackTrac…
- ASCII字符随机混淆字典的生成
- 端口复用(SO_REUSEADDR)是干啥用的…
- 正确实现和使用assert
- 《C陷阱与缺陷》书评兼感想