std::basic_string::rbegin
reverse_iterator rbegin(); | | |
---|---|---|
const_reverse_iterator rbegin() const; | | |
const_reverse_iterator crbegin() const; | | (since C++11) |
将反向迭代器返回到反向字符串的第一个字符。它对应于非反转字符串的最后一个字符。
参数
%280%29
返回值
将迭代器反向到第一个字符。
例外
(none) | (until C++11) |
---|---|
noexcept specification: noexcept | (since C++11) |
复杂性
常量。
例
二次
#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"
}
二次
产出:
二次
Exemplary
yralpmexE
二次
另见
rend crend (C++11) | returns a reverse iterator to the end (public member function) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com