名前空間
変種
操作

std::basic_string_view<CharT,Traits>::rbegin, std::basic_string_view<CharT,Traits>::crbegin

From cppreference.com
 
 
 
 
constexpr const_reverse_iterator rbegin() const noexcept;
(C++17以降)
constexpr const_reverse_iterator crbegin() const noexcept;
(C++17以降)

逆順ビューの最初の文字への逆イテレータを返します。これは、非逆順ビューの最後の文字に対応します。

range-rbegin-rend.svg

目次

[編集] パラメータ

(なし)

[編集] 戻り値

最初の文字へのconst_reverse_iterator

[編集] 複雑性

定数。

[編集]

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string_view>
 
int main()
{
    std::ostream_iterator<char> out_it(std::cout);
    std::string_view str_view("abcdef");
 
    std::copy(str_view.rbegin(), std::next(str_view.rbegin(), 3), out_it);
    *out_it = '\n';
 
    std::copy(str_view.crbegin(), std::next(str_view.crbegin(), 3), out_it);
    *out_it = '\n';
}

出力

fed
fed

[編集] 関連項目

末尾への逆イテレータを返す
(public member function) [編集]
先頭への逆イテレータを返す
(public member function of std::basic_string<CharT,Traits,Allocator>) [編集]
English 日本語 中文(简体) 中文(繁體)