Say I have a std::vector
named myVec
.
I don't know the exact size it will reach, so i use only myVec.push_back(...)
.
Can I rely on the fact that after I have pushed_back, size()-1 will give me the index of that last element? Thanks.
For non-empty vectors yes, size()-1
is the index of the last element.