◐ Shell
clean mode source ↗

std::basic_string_view<CharT,Traits>::rbegin, std::basic_string_view<CharT,Traits>::crbegin - cppreference.com

提供: cppreference.com

<tbody> </tbody>

constexpr const_reverse_iterator rbegin() const noexcept;

(C++17以上)

constexpr const_reverse_iterator crbegin() const noexcept;

(C++17以上)

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

引数

(なし)

戻り値

最初の文字を指す 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';
}

出力:

関連項目