How can I test for the last element in a vector when using BOOST_FOREACH?
-
11-11-2019 - |
Question
I have a vector which I iterate over. The final element of the vector is special case, and I'd like to test for it separately. For example, I may do something as such:
for (iterator = vector.begin(); iterator != vector.end(); ++iterator) {
if ((iterator + 1) == (vector.end())) {
...
} else {
...
}
}
I would like to replace the iterator with the BOOST_FOREACH
macro. Can a similar test for the final element be done?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow