74

为遗留代码提供STL支持(实现自定义iterator) - 简书

 6 years ago
source link: http://www.jianshu.com/p/a0a0407162c1?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
为什么 在很多情况下,集合内容被封装到特定类里,只能通过一些接口来进行访问,而如果是STL容器,则可以利用STL算法进行非常灵活、表达能力更强的操作,譬如如下类: 在对FakeVector进行操作时,只能有如下写法: 而不能像操作STL容器一样使用std::copy和std::transform来进行查询、追加操作。 目标 为现有类提供迭代器,使其能够模仿STL容器来应用STL相关算法,譬如...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK