开发者

STL iterator wrapper

开发者 https://www.devze.com 2023-03-12 17:49 出处:网络
I would like to write wrapper for STL iterator. It should only change behavior of some methods... I see it like smth like this:

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

精彩评论

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

关注公众号