g*********s 发帖数: 1782 | 1 i need to keep track of the iterators to both the head element and the
tail elements given a std::list.
using name space std;
vector::iterator > x;
x.push_back(L.begin());
x.push_back(L.end());
x.back()--;
is there any alternative to replace the last two lines?
it seems the following not working. so reverse_iterator can't be casted to
iterator in force?
x.push_back(list::iterator(L.rbegin())); |
t****t 发帖数: 6806 | 2 how about
x.push_back(--L.end());
but why do you spend time on such things...
【在 g*********s 的大作中提到】 : i need to keep track of the iterators to both the head element and the : tail elements given a std::list. : using name space std; : vector::iterator > x; : x.push_back(L.begin()); : x.push_back(L.end()); : x.back()--; : is there any alternative to replace the last two lines? : it seems the following not working. so reverse_iterator can't be casted to : iterator in force?
|
z****e 发帖数: 2024 | 3 .base()
but that's still not what you want.
difference between reverse iterator and iterator is no more close than
difference between class A; and class B;
【在 g*********s 的大作中提到】 : i need to keep track of the iterators to both the head element and the : tail elements given a std::list. : using name space std; : vector::iterator > x; : x.push_back(L.begin()); : x.push_back(L.end()); : x.back()--; : is there any alternative to replace the last two lines? : it seems the following not working. so reverse_iterator can't be casted to : iterator in force?
|
b*******s 发帖数: 5216 | 4 而且保存iterator没什么意义
iterator很容易失效 |