📄 reverseiterator.html
字号:
<tt>reverse_iterator& operator--()</tt></TD><TD VAlign=top> <A href="BidirectionalIterator.html">Bidirectional Iterator</A></TD><TD VAlign=top>Predecrement</TD></TR><TR><TD VAlign=top><tt>reverse_iterator operator--(int)</tt></TD><TD VAlign=top> <A href="BidirectionalIterator.html">Bidirectional Iterator</A></TD><TD VAlign=top>Postdecrement</TD></TR><TR><TD VAlign=top><tt>reverse_iterator operator+(Distance)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Iterator addition</TD></TR><TR><TD VAlign=top><tt>reverse_iterator& operator+=(Distance)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Iterator addition</TD></TR><TR><TD VAlign=top><tt>reverse_iterator operator-(Distance)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Iterator subtraction</TD></TR><TR><TD VAlign=top><tt>reverse_iterator& operator-=(Distance)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Iterator subtraction</TD></TR><TR><TD VAlign=top><tt>Reference operator[](Distance)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Random access to an element.</TD></TR><TR><TD VAlign=top><tt>reverse_iterator operator+(Distance, reverse_iterator)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Iterator addition. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>Distance operator-(const reverse_iterator&, const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Finds the distance between two iterators. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>bool operator==(const reverse_iterator&, const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="trivial.html">Trivial Iterator</A></TD><TD VAlign=top>Compares two iterators for equality. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>bool operator<(const reverse_iterator&, const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="RandomAccessIterator.html">Random Access Iterator</A></TD><TD VAlign=top>Determines whether the first argument precedes the second. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>random_access_iterator_tag iterator_category(const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="iterator_tags.html">Iterator tags</A></TD><TD VAlign=top>Returns the iterator's category. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>T* value_type(const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="iterator_tags.html">Iterator tags</A></TD><TD VAlign=top>Returns the iterator's value type. This is a global function, not a member function.</TD></TR><TR><TD VAlign=top><tt>Distance* distance_type(const reverse_iterator&)</tt></TD><TD VAlign=top> <A href="iterator_tags.html">Iterator tags</A></TD><TD VAlign=top>Returns the iterator's distance type. This is a global function, not a member function.</TD></tr></table><h3>New members</h3>These members are not defined in the <A href="RandomAccessIterator.html">Random Access Iterator</A> requirements,but are specific to <tt>reverse_iterator</tt>.<Table border><TR><TH>Member</TH><TH>Description</TH></TR><TR><TD VAlign=top><tt>self</tt></TD><TD VAlign=top>A typedef for <tt>reverse_iterator<<A href="RandomAccessIterator.html">RandomAccessIterator</A>, T, Reference, Distance></tt>. </TD></TR><TR><TD VAlign=top><tt><A href="RandomAccessIterator.html">RandomAccessIterator</A> base()</tt></TD><TD VAlign=top>Returns the current value of the <tt>reverse_iterator</tt>'s base iterator. If <tt>ri</tt> is a reverse iterator and <tt>i</tt> is any iterator, the two fundamental identities of reverse iterators can be written as <tt>reverse_iterator(i).base() == i</tt> and <tt>&*ri == &*(ri.base() - 1)</tt>.</TD></TR><TR><TD VAlign=top><tt>reverse_iterator(<A href="RandomAccessIterator.html">RandomAccessIterator</A> i)</tt></TD><TD VAlign=top>Constructs a <tt>reverse_iterator</tt> whose base iterator is <tt>i</tt>.</TD></tr></table><h3>Notes</h3><P><A name="1">[1]</A>There isn't really any good reason to have two separate classes:this separation is purely because of a technical limitation in some oftoday's C++ compilers. If the two classes were combined into one, then therewould be no way to declare the return types of the <A href="iterator_tags.html">iterator tag</A>functions <tt><A href="iterator_category.html">iterator_category</A></tt>, <tt><A href="distance_type.html">distance_type</A></tt> and<tt><A href="value_type.html">value_type</A></tt> correctly. The <i>iterator traits</i>class solves this problem: it addresses the same issues as the iterator tagfunctions, but in a cleaner and more flexible manner. Iteratortraits, however, rely on <i>partial specialization</i>, and manyC++ compilers do not yet implement partial specialization.Once compilers that support partial specialization become more common,these two different reverse iterator classes will be combined into a single class.<P><A name="2">[2]</A>The declarations for <tt>rfirst</tt> and <tt>rlast</tt> are written in thisclumsy form simply as an illustration of how to declare a<tt>reverse_iterator</tt>. <tt><A href="Vector.html">Vector</A></tt> is a <A href="ReversibleContainer.html">Reversible Container</A>, so itprovides a typedef for the appropriate instantiation of<tt>reverse_iterator</tt>. The usual way of declaring these variablesis much simpler:<pre> vector<T>::reverse_iterator rfirst = rbegin(); vector<T>::reverse_iterator rlast = rend();</pre><P><A name="3">[3]</A>Note the implications of this remark. The variable <tt>rfirst</tt> isinitialized as <tt>reverse_iterator<...> rfirst(V.end());</tt>. The valueobtained when it is dereferenced, however, is <tt>*(V.end() - 1)</tt>. Thisis a general property: the fundamental identity of reverse iteratorsis <tt>&*(reverse_iterator(i)) == &*(i - 1)</tt>. This code sample shows whythis identity is important: if <tt>[f, l)</tt> is a valid range, then itallows <tt>[reverse_iterator(l), reverse_iterator(f))</tt> to be a validrange as well. Note that the iterator <tt>l</tt> is not part of the range,but it is required to be dereferenceable or past-the-end. There is norequirement that any such iterator precedes <tt>f</tt>.<h3>See also</h3><A href="ReversibleContainer.html">Reversible Container</A>, <A href="ReverseBidirectionalIterator.html">reverse_bidirectional_iterator</A>,<A href="RandomAccessIterator.html">Random Access Iterator</A>, <A href="iterator_tags.html">iterator tags</A>,<A href="Iterators.html">Iterator Overview</A><!-- start footer --><!-- Footer Begins --><STYLE TYPE="text/css"><!--TD.footer, TD.footer A{ font-family: Arial, helvetica, sans-serif; font-size: 8pt;}A.home {font-family: Arial, helvetica, sans-serif;}--></STYLE><P><A CLASS="home" HREF="index.html">STL Home</A><P><TABLE WIDTH="600" CELLPADDING="0" CELLPADDING="0" BORDER="0"> <TR> <TD ALIGN="RIGHT" CLASS="footer"><A HREF="/company_info/terms.html" TARGET="_top">terms of use</A> | <A HREF="/company_info/privacy.html" TARGET="_top">privacy policy</A></TD> <TD ALIGN="CENTER" CLASS="footer"> | </TD> <TD ALIGN="LEFT" CLASS="footer"><A HREF="/cgi-bin/feedback/" TARGET="_top">contact us</A></TD> </TR><TR> <TD ALIGN="RIGHT" CLASS="footer">Copyright © 1993-2003 Silicon Graphics, Inc. All rights reserved.</TD> <TD ALIGN="CENTER" CLASS="footer"> | </TD> <TD ALIGN="LEFT" CLASS="footer"><A HREF="/company_info/trademarks/" TARGET="_top">Trademark Information</A></TD> </TR></TABLE><!-- Footer Ends --><!-- end footer --><P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -