如何递增迭代器2? [英] How to increment an iterator by 2?

查看:178
本文介绍了如何递增迭代器2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何将迭代器增加2?

Can anybody tell me how to increment the iterator by 2?

iter ++ iter + 2 ?如何实现这一点?

iter++ is available - do I have to do iter+2? How can I achieve this?

推荐答案

std :: advance(iter,2);

为不是随机访问迭代器的迭代器工作,但是当与随机访问迭代器一起使用时,仍然可以通过实现专门化的迭代器的效率不低于 iter + = 2

This method will work for iterators that are not random-access iterators but it can still be specialized by the implementation to be no less efficient than iter += 2 when used with random-access iterators.

这篇关于如何递增迭代器2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆