开发者

STL iterator wrapper

I would like to write wrapper for STL iterator. It should only change behavior of some methods...

I see it like smth like this:

template<***>
class custom_iterator : public ***
{
    T & iter;

public:
    custom_iterator(T & iter) : iter(iter) {}

    // for example, be开发者_Go百科haviour that increments value
    T_val operator * () { return (*iter)+1; } 
};

How it can be made for all types of iterators? I mean:

  • Input Iterator
  • Output Iterator
  • Forward Iterator
  • Bidirectional Iterator
  • Random Access Iterator

How it is possible?


Take a look at boost::transform_iterator. I think that's what you're trying to get at.

Source code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜