[英]Iterator arithmetic
In c++ STL, if I have an iterator it
into a vector v
, is it - v.begin()
guaranteed to give me the index into the vector, so that *it == v[it - v.begin()]
? 在C ++ STL,如果我有一个迭代
it
到载体v
,是it - v.begin()
保证给我的索引入载体,使得*it == v[it - v.begin()]
? If so, is this true for all random access iterators? 如果是这样,对于所有随机访问迭代器都是如此吗?
是的,它是,并且所有RA迭代器都是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.