std::ranges:: crend
|
定義先ヘッダ
<ranges>
|
||
|
定義先ヘッダ
<iterator>
|
||
|
inline
namespace
/* unspecified */
{
inline
constexpr
/* unspecified */
crend
=
/* unspecified */
;
|
(C++20以降)
(カスタマイゼーションポイントオブジェクト) |
|
|
呼び出しシグネチャ
|
||
|
template
<
class
T
>
requires
/* see below */
|
(C++20以降) | |
定数イテレータの終端を示すセンチネルを返します (定数イテレータ用) (C++23以降) 。これは、逆順シーケンスとして扱われる const修飾された (C++23以前) 範囲の終端を示します。
|
|
(C++23以前) |
|
引数が左辺値、または
ranges::
enable_borrowed_range
<
std::
remove_cv_t
<
T
>>
が
true
の場合、
それ以外の場合、
|
(C++23以降) |
式
e
に対して
ranges
::
crend
(
e
)
が有効であり、
decltype
(
(
e
)
)
が
T
である場合、
CT
は
std::ranges::range
をモデルし、かつ
(C++23未満)
std::
sentinel_for
<
S, I
>
が常に
true
となる。ここで
S
は
decltype
(
ranges
::
crend
(
e
)
)
、
I
は
decltype
(
ranges::
crbegin
(
e
)
)
である。
さらに、
S
が
input_iterator
をモデルする場合は、
S
は
constant-iterator
もモデルする。
(C++23以上)
カスタマイゼーションポイントオブジェクト
名前
ranges::crend
は
カスタマイゼーションポイントオブジェクト
を表し、これは
関数オブジェクト
のconst版で、
リテラル型
semiregular
クラス型である。詳細は
CustomizationPointObject
を参照。
例
#include <algorithm> #include <iostream> #include <iterator> #include <vector> int main() { int a[]{4, 6, -3, 9, 10}; std::cout << "Array backwards: "; namespace ranges = std::ranges; ranges::copy(ranges::rbegin(a), ranges::rend(a), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; std::cout << "Vector backwards: "; std::vector v{4, 6, -3, 9, 10}; ranges::copy(ranges::rbegin(v), ranges::rend(v), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; }
出力:
Array backwards: 10 9 -3 6 4 Vector backwards: 10 9 -3 6 4
関連項目
|
(C++20)
|
範囲に対する逆方向終端イテレータを返す
(カスタマイゼーションポイントオブジェクト) |
|
(C++14)
|
コンテナまたは配列に対する逆方向終端イテレータを返す
(関数テンプレート) |