advance和next的功能是获取下一个元素,但是这两个操作有一点不同
std::advance
- modifies its argument
会修改迭代器本身的值 - returns nothing
返回值是void,也就是不返回值 - works on input iterators or better (or bi-directional iterators if a negative distance is given)
std::next
- leaves its argument unmodified
不改变迭代器的值 - returns a copy of the argument, advanced by the specified amount
返回指定的值元素的值 - works on forward iterators or better (or bi-directional iterators if a negative distance is given))
https://stackoverflow.com/questions/15017065/whats-the-difference-between-stdadvance-and-stdnext
原文链接: https://www.cnblogs.com/MalcolmMeng/p/10816036.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/294712
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!