std::basic_string<CharT,Traits,Allocator>::rbegin, std::basic_string<CharT,Traits,Allocator>::crbegin - cppreference.com
提供: cppreference.com
<tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody>
| (1) | ||
|
|
(C++11未満) | |
|
|
(C++11以上) (C++20未満) |
|
|
|
(C++20以上) | |
| (2) | ||
|
|
(C++11未満) | |
|
|
(C++11以上) (C++20未満) |
|
|
|
(C++20以上) | |
| (3) | ||
|
|
(C++11以上) (C++20未満) |
|
|
|
(C++20以上) | |
逆になった文字列の最初の文字を指す逆イテレータを返します。 これは逆になっていない文字列の最後の文字に対応します。
引数
(なし)
戻り値
最初の文字を指す逆イテレータ。
計算量
一定。
例
#include <iostream> #include <algorithm> #include <iterator> #include <string> int main() { std::string s("Exemplar!"); *s.rbegin() = 'y'; std::cout << s << '\n'; // "Exemplary" std::string c; std::copy(s.crbegin(), s.crend(), std::back_inserter(c)); std::cout << c << '\n'; // "yralpmexE" }
出力: