I've never walked into the following problem with iterators, so I really do not know where the solution might start. I have a LIST "StringOfPearls" which is permuted right before I do the following:
DNAr = StringOfPearls->begin(); // Added 1 element to the beginning of this list in earlier line of code
cout << "pos DNAr before bumping by 1: " << distance(DNAreplicase, StringOfPearls->begin()) << endl;
advance(DNAreplicase, 1);
cout << "pos DNAr after bumping by 1: " << distance(DNAreplicase, StringOfPearls->begin()) << endl;
Returns:
pos DNAr before bumping by 1: 0
pos DNAr after bumping by 1: 10
No doubt I'm just missing something silly, but can anyone help me out?
You are not using
std::distance
correctly.begin
iterator is the first argument, e.g.This is the convention for all functions taking pairs of iterators denoting a range.