std::basic_string<CharT,Traits,Allocator>::rend, std::basic_string<CharT,Traits,Allocator>::crend
ja.cppreference.net より
reverse_iterator rend();
|
(1) | (C++11 から noexcept) (C++20 から constexpr) |
const_reverse_iterator rend() const;
|
(2) | (C++11 から noexcept) (C++20 から constexpr) |
const_reverse_iterator crend() const noexcept;
|
(3) | (C++11 から) (C++20 から constexpr) |
逆順の文字列の最後の文字の次の文字を指す逆イテレータを返します。これは、元の(逆順でない)文字列の最初の文字の前の文字に相当します。この文字はプレースホルダとして機能し、それにアクセスしようとすると未定義動作になります。
パラメータ
(なし)
戻り値
最後の文字の次の文字を指す逆イテレータ。
計算量
定数。
注記
libc++は
crend()
をC++98モードにバックポートします。
例
このコードを実行
#include <algorithm> #include <iostream> #include <iterator> #include <string> int main() { std::string p("[A man, a plan, a canal: Panama]"); std::string q; std::copy(p.crbegin(), p.crend(), std::back_inserter(q)); std::cout << "q = " << q << '\n'; std::copy(q.crbegin(), q.crend(), p.rbegin()); std::cout << "p = " << p << '\n'; }
出力:
q = ]amanaP :lanac a ,nalp a ,nam A[ p = ]amanaP :lanac a ,nalp a ,nam A[
関連項目
|
(C++11)
|
先頭への逆イテレータを返す
(公開メンバ関数) |
|
終端への逆イテレータを返す
( std::basic_string_view<CharT,Traits>の公開メンバ関数)
|