I'm trying to demonstrate an Insertion sort on a STL list for class I'm in. I'm running into an issue where the second expression of the while loop is never true, so the inner loop doesn't run. Should I be decrementing the iterator in a different way? I'm seeding a test list with random values but the function doesn't swap any values. "front" and "end" will be passed in with the values myList.begin() and myList.end().
template <typename dT>
void ListSort(list<dT>& lis, typename list<dT>::iterator front, typename list<dT>::iterator end) {
auto start = ++front;
for (; start != end; start++) {
auto curr = start;
while (curr != front && *curr < *(curr--)) {
swap(*curr, *(curr--));
curr--;
}
}
}