s*****g 发帖数: 5159 | 1 The operator [] of a vector returns the reference to an element of the vecto
r
member function .end() returns an iterator of the last element of the vector
.
I want to judge if a particular element is the last element of the vector, b
ut I cannot do the following |
s*****g 发帖数: 5159 | 2 Solved by
vec.end() -------> vec.back()
vecto
vector
b
【在 s*****g 的大作中提到】 : The operator [] of a vector returns the reference to an element of the vecto : r : member function .end() returns an iterator of the last element of the vector : . : I want to judge if a particular element is the last element of the vector, b : ut I cannot do the following
|
z****e 发帖数: 2024 | 3 vec.end() is pass-the-end element.
vec.rbegin() can be dereferenced to the last element you want
also.
back() is the standard answer. |
s*****g 发帖数: 5159 | 4 Thank you.
【在 z****e 的大作中提到】 : vec.end() is pass-the-end element. : vec.rbegin() can be dereferenced to the last element you want : also. : back() is the standard answer.
|