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

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2021-05-09
  • 2021-06-25
  • 2021-07-01
  • 2021-09-11
  • 2021-10-10
猜你喜欢
  • 2021-06-28
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-11-04
  • 2022-01-08
  • 2021-10-30
相关资源
相似解决方案