public member function
<string>

std::basic_string::crbegin

const_reverse_iterator crbegin() const noexcept;
返回指向反向起始位置的 const_reverse_iterator
返回一個const_reverse_iteratorpointing to the last character of the string (i.e., its reverse beginning).

引數



返回值

Aconst_reverse_iteratorto the reverse beginning of the string.

成員型別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;
}

輸出
muspi merol


複雜度

未指定,但通常是恆定的。

迭代器有效性

沒有變化。

資料競爭

該物件被訪問。

異常安全

無異常保證:此成員函式從不丟擲異常。
還可以保證返回的迭代器的複製構造或賦值永遠不會引發異常。

另見