A list has a bidirectional iterator only (You can only increment or decrement the iterator via ++ or --). To advance the iterator by three you could std::advance(it, 3), but that might pass the end and lead to an infinite loop / undefined behavior.
Hence:
#include <iostream>
#include <list>
int main()
{
std::list<int> foo;
for (int i = 0; i < 20; i++) {
foo.push_back(i);
}
std::list<int>::iterator it = foo.begin();
while(it != foo.end()) {
std::cout << *it << ' ';
// Advance by three, stop at end
for(int i = 0; i < 3 && it != foo.end(); ++i, ++it);
}
return 0;
}
Note: You might choose a different container supporting random access (std::array, std::vector, std::deque) instead.