std::rend, std::crend
| ヘッダ <array>
|
||
| で定義 <deque>
|
||
| ヘッダ <flat_map>
|
(C++23以降) で定義 |
|
| ヘッダ <flat_set>
|
(C++23以降) で定義 |
|
| ヘッダ <forward_list>
|
||
ヘッダ |
||
| (C++26以降) で定義 <iterator>
|
||
| ヘッダ <list>
|
||
| で定義 <map>
|
||
| ヘッダ <optional>
|
(C++26以降) で定義 |
|
| ヘッダ <regex>
|
||
| で定義 <set>
|
||
| ヘッダ <span>
|
(C++20以降) で定義 |
|
| ヘッダ <stacktrace>
|
(C++23以降) で定義 |
|
| ヘッダ <string>
|
||
ヘッダ |
||
| (C++17以降) で定義 <unordered_map>
|
||
| ヘッダ <unordered_set>
|
||
| で定義 <valarray>
|
||
| ヘッダ <vector>
|
||
template< class C >
auto rend( C& c ) noexcept(noexcept(c.rend()))
-> decltype(c.rend());
|
(1) | (C++14以降) (constexpr C++17以降) |
template< class C >
auto rend( const C& c ) noexcept(noexcept(c.rend()))
-> decltype(c.rend());
|
(2) | (C++14以降) (constexpr C++17以降) |
template< class T, std::size_t N >
std::reverse_iterator<T*> rend( T (&array)[N] ) noexcept;
|
(3) | (C++14以降) (constexpr C++17以降) |
template< class T >
std::reverse_iterator<const T*> rend( std::initializer_list<T> il ) noexcept;
|
(4) | (C++14以降) (constexpr C++17以降) |
template< class C >
auto crend( const C& c ) noexcept(noexcept(std::rend(c)))
-> decltype(std::rend(c));
|
(5) | (C++14以降) (constexpr C++17以降) |
指定された範囲の逆終端へのイテレータを返します。
c.rend() を返します。これは通常、c で表されるシーケンスの逆終端の1つ後ろを指すイテレータです。std::reverse_iterator<T*> の逆終端への array オブジェクトを返します。std::reverse_iterator<const T*> の逆終端への il オブジェクトを返します。std::end(c) を返します。c は常に const 修飾されているものとして扱われます。
パラメータ
| c | - |
rendメンバ関数を持つコンテナまたはビュー
|
| array | - | 任意の型の配列 |
| il | - | std:: initializer_list |
戻り値
例外
実装定義の例外をスローする可能性があります。
オーバーロード
適切な
rend()
メンバ関数を公開していないが、反復処理が可能なクラスおよび列挙型に対して、
rend
のカスタムオーバーロードを提供することができます。
|
実引数依存の名前探索
によって発見された
|
(C++20以降) |
注記
std::initializer_list
のオーバーロードは、
rend
メンバ関数を持たないため必要です。
例
#include <algorithm> #include <iostream> #include <iterator> #include <vector> int main() { int a[]{4, 6, -3, 9, 10}; std::cout << "C-style array `a` backwards: "; std::copy(std::rbegin(a), std::rend(a), std::ostream_iterator<int>(std::cout, " ")); auto il = {3, 1, 4}; std::cout << "\nstd::initializer_list `il` backwards: "; std::copy(std::rbegin(il), std::rend(il), std::ostream_iterator<int>(std::cout, " ")); std::vector<int> v{4, 6, -3, 9, 10}; std::cout << "\nstd::vector `v` backwards: "; std::copy(std::rbegin(v), std::rend(v), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; }
出力:
C-style array `a` backwards: 10 9 -3 6 4 std::initializer_list `il` backwards: 4 1 3 std::vector `v` backwards: 10 9 -3 6 4
欠陥報告
以下の動作を変更する欠陥報告は、以前に公開されたC++標準に遡及的に適用されました。
| DR | 適用先 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3537 | C++14 | std::rend および std::crend は例外指定を伝播することが必要とされていませんでした
|
必要 |
関連項目
|
(C++11)
(C++14)
|
コンテナまたは配列の終端を指すイテレータを返す
(関数テンプレート) |
|
(C++14)
|
コンテナまたは配列の先頭を指す逆方向イテレータを返す
(関数テンプレート) |
|
(C++11)
(C++14)
|
コンテナまたは配列の先頭を指すイテレータを返す
(関数テンプレート) |
|
(C++20)
|
範囲の逆方向終端イテレータを返す
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
読み取り専用範囲の逆方向終端イテレータを返す
(カスタマイゼーションポイントオブジェクト) |