编写适合整合到STL的C ++容器 [英] Write C++ container that fits neatly into STL

查看:157
本文介绍了编写适合整合到STL的C ++容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个非常整齐地放在STL中的样式写一个容器类。它应该看起来像在标准STL容器的位置。

I would like to write a container class in a style which fits very neatly into STL. It should look and behave as if it where a standard STL container.

有手册,报告,Q& A等,描述如何写代码与这些集的功能?这样的文本应该妥协STL的设计原则,陷阱,编码约定等。

Is there a manual, report, Q&A, etc., out there that describes how to write code with these set of features? Such a text should compromise design principles of the STL, pitfalls, coding conventions, and the like.

PS:这个问题的部分灵感来自于: C ++向量与动态项目大小虽然这个想法不是关于模板类。

PS: This question has been partly inspired by that one: C++ vector with dynamic item size although that idea is not about template classes.

推荐答案

这不是很困难(对于简单的数据结构)。您应该阅读关于C ++标准中的容器的章节。您可以在这里下载即将推出的C ++ 1x标准的草稿:

It is not very difficult (for simple data stuctures). You should read the chapter about containers in the C++ standard. You can download the draft of the upcoming C++1x standard here :

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/#mailing2011-04 a>

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf

在编写迭代器时,您可能需要使用boost :: iterateror_facade。

You might want to use boost::iterateror_facade when writing the iterators.

http://www.boost.org/doc/libs/1_46_1/libs/iterator/doc/iterator_facade.html

这篇关于编写适合整合到STL的C ++容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆