I am very confused by what the following two iterators point to in the code below.
list<fieldT>::iterator steeperField = currentField;
list<fieldT>::iterator shallowerField =
activeFields.insert(currentField, *currentField);
If we assume that activeFields (the list these iterators pertain to) has indexes 0,1,2 (count=3), and also that currentField is presently pointing at 1. Then I imagine:
- steeperField is set to index 1.
- a fieldT is inserted into the list at index 1, and returns an iterator that starts at index 1.
Therefor, steeperField should be pointing to the same location as shallowField. This does not seem to be what's happening: shallowerField appears to point to index 2. Why?
activeFields
is a parameter passed as list<fieldT> & activeFields
. currentField
is a parameter passed as list<fieldT>::iterator & currentField
. currentField
is initially started via a call to currentField = activeFields.begin();
.