名前空間
変種
操作

std::basic_string<CharT,Traits,Allocator>::rbegin, std::basic_string<CharT,Traits,Allocator>::crbegin

提供: cppreference.com
< cpp‎ | string‎ | basic string
 
 
 
std::basic_string
 
(1)
reverse_iterator rbegin();
(C++11未満)
reverse_iterator rbegin() noexcept;
(C++11以上)
(C++20未満)
constexpr reverse_iterator rbegin() noexcept;
(C++20以上)
(2)
const_reverse_iterator rbegin() const;
(C++11未満)
const_reverse_iterator rbegin() const noexcept;
(C++11以上)
(C++20未満)
constexpr const_reverse_iterator rbegin() const noexcept;
(C++20以上)
(3)
const_reverse_iterator crbegin() const noexcept;
(C++11以上)
(C++20未満)
constexpr const_reverse_iterator crbegin() const noexcept;
(C++20以上)

逆になった文字列の最初の文字を指す逆イテレータを返します。 これは逆になっていない文字列の最後の文字に対応します。

range-rbegin-rend.svg

目次

[編集] 引数

(なし)

[編集] 戻り値

最初の文字を指す逆イテレータ。

[編集] 計算量

一定。

[編集]

#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

[���集] 関連項目

終端を指す逆イテレータを返します
(パブリックメンバ関数) [edit]