15,884,388 members
Home / Discussions / ATL / WTL / STL

# ATL / WTL / STL

 First PrevNext
 HOW TO ANSWER A QUESTION Chris Maunder16-Jul-09 3:09 Chris Maunder 16-Jul-09 3:09
 How to get an answer to your question Chris Maunder16-Jul-09 3:05 Chris Maunder 16-Jul-09 3:05
 AI Ted Snyders18-Nov-23 9:52 Ted Snyders 18-Nov-23 9:52
 Re: AI RedDk18-Nov-23 14:44 RedDk 18-Nov-23 14:44
 Help with STL list::insert ForNow21-Sep-22 1:54 ForNow 21-Sep-22 1:54
 Re: Help with STL list::insert Graham Breach21-Sep-22 21:40 Graham Breach 21-Sep-22 21:40
 Re: Help with STL list::insert ForNow22-Sep-22 1:35 ForNow 22-Sep-22 1:35
 Re: Help with STL list::insert Graham Breach22-Sep-22 3:40 Graham Breach 22-Sep-22 3:40
 Re: Help with STL list::insert ForNow22-Sep-22 4:31 ForNow 22-Sep-22 4:31
 Re: Help with STL list::insert Graham Breach22-Sep-22 4:59 Graham Breach 22-Sep-22 4:59
 Re: Help with STL list::insert ForNow22-Sep-22 5:11 ForNow 22-Sep-22 5:11
 Re: Help with STL list::insert Richard MacCutchan22-Sep-22 4:51 Richard MacCutchan 22-Sep-22 4:51
 Re: Help with STL list::insert ForNow22-Sep-22 9:30 ForNow 22-Sep-22 9:30
 Re: Help with STL list::insert Richard MacCutchan22-Sep-22 22:28 Richard MacCutchan 22-Sep-22 22:28
 I think you missed the point. The begin and end iterators are dynamic and are recalculated every time you insert or remove an element from the list. In your case you capture the begin iterator which points to the first element of the list. You then insert an item at the front of the list, so your saved iterator is no longer valid. You then increment it so it could, quite reasonably, point beyond the end of the list. To use iterators properly you must call the `begin` and `end` methods of the list each time you need their values.
 Re: Help with STL list::insert ForNow23-Sep-22 1:45 ForNow 23-Sep-22 1:45
 Re: Help with STL list::insert Richard MacCutchan23-Sep-22 1:55 Richard MacCutchan 23-Sep-22 1:55
 Re: Help with STL list::insert ForNow23-Sep-22 2:20 ForNow 23-Sep-22 2:20
 Re: Help with STL list::insert Richard MacCutchan23-Sep-22 3:16 Richard MacCutchan 23-Sep-22 3:16
 Re: Help with STL list::insert ForNow23-Sep-22 4:11 ForNow 23-Sep-22 4:11
 Re: Help with STL list::insert Richard MacCutchan23-Sep-22 4:38 Richard MacCutchan 23-Sep-22 4:38
 Re: Help with STL list::insert ForNow23-Sep-22 4:48 ForNow 23-Sep-22 4:48
 Message Closed 19-Jul-22 5:14 Member 14968771 19-Jul-22 5:14
 Re: error: cannot call member function ‘bool QRegExp::exactMatch(const QString&) const’ without object jsc4219-Jul-22 6:35 jsc42 19-Jul-22 6:35
 /std:c++20 broke a template class Member 1567106212-Jun-22 10:07 Member 15671062 12-Jun-22 10:07
 Re: /std:c++20 broke a template class longjmp24-Nov-22 2:59 longjmp 24-Nov-22 2:59
 Last Visit: 31-Dec-99 18:00     Last Update: 23-Apr-24 15:08 Refresh 1234567891011 Next ᐅ