最終更新日時(UTC):
が更新

履歴 編集

function
<set>

std::set::crend(C++11)

const_reverse_iterator crend() const noexcept;

概要

set コンテナの先頭要素の前(これは反転シーケンスの末尾にあたる)を指す読み取り専用逆イテレータを取得する。

戻り値

反転シーケンスの終端を指す読み取り専用逆イテレータ。

const_reverse_iterator はメンバ型である。set クラステンプレートにおいて、これは双方向イテレータであり、reverse_iterator<const_iterator> と定義される。

#include <iostream>
#include <set>
#include <algorithm>

int main()
{
  std::set<int> c = {3, 1, 2};

  // このアルゴリズム内ではcの書き換えを決して行わない
  std::for_each(c.crbegin(), c.crend(), [](const int& x) {
    std::cout << x << std::endl;
  });
}

出力

3
2
1

関連項目

名前 説明
crbegin 末尾を指す読み取り専用逆イテレータを返す
cbegin 先頭を指す読み取り専用イテレータを返す
cend 末尾の次を指す読み取り専用イテレータを返す