Slicing a vector

后端 未结 8 1981
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 01:12

I have a std::vector. I want to create iterators representing a slice of that vector. How do I do it? In pseudo C++:

class InterestingType;

void doSomethi         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 01:54

    As others have said, you can represent the "slice" as pair of iterators. If you are willing to use Boost, you can use the range concept. Then you will have even begin()/end() member functions available and the whole thing looks a lot like a container.

提交回复
热议问题