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

履歴 編集

function
<set>

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

const_iterator cbegin() const noexcept;

概要

set コンテナの先頭要素を参照する読み取り専用イテレータを取得する。

戻り値

コンテナの先頭要素への読み取り専用イテレータ。

計算量

定数時間。

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

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

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

出力

1
2
3

関連項目

名前 説明
set::cend 末尾の次を指す読み取り専用イテレータを取得する
set::rbegin 末尾を指す逆イテレータを取得する
set::rend 先頭の前を指す逆イテレータを取得する