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

履歴 編集

function
<forward_list>

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

const_iterator cbegin() const noexcept;

概要

先頭の要素を指す読み取り専用イテレータを取得する。

戻り値

先頭要素を指す読み取り専用イテレータ

例外

投げない

#include <iostream>
#include <forward_list>
#include <algorithm>

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

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

出力

1
2
3

バージョン

言語

  • C++11

処理系

参照