简体   繁体   中英

Is there something like circular_advance avaliable in std or boost?

lets say I want to go through container in a circular way:

idx = 0, idx =1 .. idx = size()-1, idx =0, idx =1 ...

Is there a way to do in with std or boost? I know that algorithms operate on ranges not on containers so I guess Im out of luck, but I just wanted to check.

PS No need for manual implementations, it is trivial(if you dont forget about seq points :P ), just

curr_idx= (curr_idx+1) % my_cont.size()

我不知道类似的任何功能,但是此答案显示了如何使用Boost.Iterator创建在集合上循环的迭代器适配器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM