1 2 3 4 5 6 7 8
int j = 0; for (list<int>::iterator pos = v.begin(); pos != v.end(); ++pos) { std::next(pos, 1); if (*pos == x) { pos_list.push_back(j); } ++j; }