Why does a push_back on an std::list change a reverse iterator initialized with rbegin?

前端 未结 3 1928
失恋的感觉
失恋的感觉 2020-12-01 12:24

According to some STL documentation I found, inserting or deleting elements in an std::list does not invalidate iterators. This means that it is allowed to loop over a list

3条回答
  •  执笔经年
    2020-12-01 13:17

    Try using an iterator for both. Try:

    std::list::iterator i = testList.end(); 
    

    and reverse through with --i

提交回复
热议问题