public member function
<string>
const_reverse_iterator crend() const noexcept;
返回指向反向結尾的const_reverse_iterator
返回一個const_reverse_iterator指向字串的第一個字元之前的理論字元(被認為是它的反向結尾)的常量反向迭代器。
返回值
Aconst_reverse_iterator到字串的反向結尾。
成員型別const_reverse_iterator是一個反向隨機訪問迭代器型別,它指向一個常量字元。
示例
1 2 3 4 5 6 7 8 9 10 11 12 13
|
// string::crbegin/crend
#include <iostream>
#include <string>
int main ()
{
std::string str ("lorem ipsum");
for (auto rit=str.crbegin(); rit!=str.crend(); ++rit)
std::cout << *rit;
std::cout << '\n';
return 0;
}
|
輸出
異常安全
無異常保證:此成員函式從不丟擲異常。
還可以保證返回的迭代器的複製構造或賦值永遠不會引發異常。