c++ stl what does base() do

前端 未结 2 613
栀梦
栀梦 2021-02-03 22:33

I have such code :

vector  v;
for (int i=0; i<5; i++)
        v.push_back(i);
v.erase(find(v.rbegin(), v.rend(),2).base());

This

2条回答
  •  天涯浪人
    2021-02-03 22:53

    base() returns the underlying base iterator.

    The base iterator refers to the element that is next to the element the reverse_iterator is currently pointing to. That is std::reverse_iterator(it).base() == std::next(it).

    You can learn more about reverse_iterator here.

提交回复
热议问题