Creating my own Iterators

前端 未结 6 1715
鱼传尺愫
鱼传尺愫 2020-11-29 15:58

I\'m trying to learn C++ so forgive me if this question demonstrates a lack of basic knowledge, you see, the fact is, I have a lack of basic knowledge.

I want some h

6条回答
  •  广开言路
    2020-11-29 16:18

    You should use Boost.Iterators. It contains a number of templates and concepts to implement new iterators and adapters for existing iterators. I have written an article about this very topic; it's in the December 2008 ACCU magazine. It discusses an (IMO) elegant solution for exactly your problem: exposing member collections from an object, using Boost.Iterators.

    If you want to use the stl only, the Josuttis book has a chapter on implementing your own STL iterators.

提交回复
热议问题