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.
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: This question has been partly inspired by that one: C++ vector with dynamic item size although that idea is not about template classes.
Containers are the objects used to store multiple elements of the same type or different. Depending on that they can be further classified as − Sequence containers (array, vector, list) Associative containers (set, map, multimap) Unordered Associative containers (unordered_set, unordered_map)
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
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With