During the running of a modern C++ range-based for loop on a std::vector
or c arrays. My initial guess would be no unless you use pointers and pointer math but just wanted to check. What I want to do is to check the adjacent elements to examine how because they might effect my current code. I also know that there is more that on item in the vector. The code would like something like:
std::vector<Item> v;
// do work
for(auto& item : v)
{
//do more work
auto pos = //some way to find get the position
if(/*pos is the first position*/)
{
process(item, pos+1);
}
else if(/*pos is the last position*/)
{
process(item, pos-1);
}
else
{
process(item, pos-1, pos+1);
}
}
I do not care about iterator if the object is a first object last object or middle object.