原文地址:http://www.cplusplus.com/reference/array/array/crend/
std::array::crend
const_iterator crend() const noexcept;
Returns a const_reverse_iterator pointing to the theoretical element preceding the first element in the vector, which is considered its reverse end.返回一个const_reverse_iterator指向理论上存在于数组第一个元素之前位置的元素,这个元素被认为是翻转的超尾元素。
A const_reverse_iterator is an iterator that points to const content and iterates in reverse order. This iterator can be increased and decreased (unless it is itself also const), just like the iterator returned by array::rend,
but it cannot be used to modify the contents it points to.
一个const_reverse_iterator是一个类似指向常量的iterator,并且是逆序的,这个迭代器可以被递增以及递减(除非本身是const),就跟rend一样,但是不能用于修改元素。
例子:
#include <iostream> #include <array> using namespace std; int main() { array<double,5> ai={0.1,0.3,0.5,0.7,0.9}; for(auto it=ai.crend();it>=ai.crbegin();it--) cout<<*it<<endl; }
运行结果:
我这里对超尾迭代器解除引用只是为了试验,注意的是不要对超尾迭代器解除引用!
其递增递减的顺序也要注意。
Parameters
none
Return Value
A const_reverse_iterator to the reverse end of the sequence.
返回一个const_reverse_iterator指向序列的超尾元素。
Member type const_reverse_iterator is a reverse random access iterator type that points to a const element
(see array member types).
迭代器属于随机迭代器。
Example
|
|
Output:
myarray backwards: 60 50 40 30 20 10
|
Complexity
Constant.
Iterator validity
No changes.
Data races
No contained elements are accessed by the call, but the iterator returned can be used to access them. Concurrently accessing or modifying different elements is safe.
容器的元素不会被访问,但是返回的迭代器可以被用来访问元素,同时访问以及修改其他元素是安全的。
Exception safety
No-throw guarantee: this member function never throws exceptions.
The copy construction or assignment of the returned iterator is also guaranteed to never throw.
通过复制构造器以及赋值构造获得的该iterator也保证不会抛出异常。
——————————————————————————————————————————————————————————————————
//翻译的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。
转载请注明出处:http://blog.csdn.net/qq844352155
author:天下无双
Email:coderguang@gmail.com
2014-8-27
于GDUT
——————————————————————————————————————————————————————————————————