std::reverse_iterator是一种迭代器适配器,它反转给定迭代器的方向,该迭代器必须至少是老式双向迭代器(LegacyBidirectionalIterator)或实现bidirectional_iterator(C++20 起)。换言之,提供双向迭代器时,std::reverse_iterator产生一个新的迭代器,它从底层的双向迭代器所定义的序列的末尾移动到开端。
底层迭代器指代(相对于 iterator_type 的)reverse_iterator 当前所指元素的下一个元素。即 &*(*this.base() - 1) == &*(*this)。 示例运行此代码 #include <iostream> #include <iterator> #include <vector> int main() { std::vector<int> v = {0, 1, 2, 3, 4, 5}; using RevIt = std:...
__cpp_lib_make_reverse_iterator201402L(C++14)std::make_reverse_iterator Example Run this code #include <algorithm>#include <iostream>#include <iterator>#include <vector>intmain(){std::vector<int>v{1,3,10,8,22};std::sort(v.begin(), v.end());std::copy(v.begin(), v.end(),std:...
The base iterator refers to the element that is next (from thestd::reverse_iterator::iterator_typeperspective) to the element thereverse_iteratoris currently pointing to. That is&*(rit.base()-1)==&*rit. Parameters (none) Return value ...
returns an iterator to the end (public member function) rbegincrbegin (C++11) returns a reverse iterator to the beginning (public member function) rendcrend (C++11) returns a reverse iterator to the end (public member function) Capacity
returns a reverse iterator to the end The text has been machine-translated viaGoogle Translate. You can help to correct and verify the translation. Clickherefor instructions. (öffentliche Elementfunktion)[edit] Kapazität Original: Capacity ...
());std::reverse_copy(a2.begin(), a2.end(),std::ostream_iterator<int>(std::cout, " "));std::cout << '\n';// ranged for loop is supportedfor (const auto& s: a3)std::cout << s << ' ';// deduction guide for array creation (since C++17)[[maybe_unused]] std::array ...
returns a reverse iterator to the end The text has been machine-translated viaGoogle Translate. You can help to correct and verify the translation. Clickherefor instructions. (öffentliche Elementfunktion)[edit] Kapazität Original: Capacity ...
equalrangeSyntaxpairITERATORiteratorequalrangeconstKEYTYPEkeyequalrange函数返回两个迭代器——一个指向第一个键值为key的元素另一个指向最后一个键值为key的元素。erase语法voideraseiteratorposvoideraseiteratorstartiteratorendsizetypeeraseconstKEYTYPEkeyerase函数删除在pos位置的元素或者删除在start和end之间的元素或者...
reverse_iterator std::reverse_iterator<iterator> [edit] const_reverse_iterator std::reverse_iterator<const_iterator> [edit] Fonctions membres (constructeur) Construit le list (fonction membre publique) [edit] (destructeur) détruit le list (fonction membre publique) [edit] operator=...