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

履歴 編集

function
<forward_list>

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

iterator begin() noexcept;           // (1) C++11
constexpr iterator begin() noexcept; // (1) C++26

const_iterator begin() const noexcept;           // (2) C++11
constexpr const_iterator begin() const noexcept; // (2) C++26

概要

先頭要素を指すイテレータを取得する。

戻り値

先頭要素を指すイテレータ

例外

投げない

#include <iostream>
#include <forward_list>

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

  decltype(ls)::iterator i = ls.begin();
  decltype(ls)::const_iterator ci = cls.begin();

  std::cout << *i << std::endl;
  std::cout << *ci << std::endl;
}

出力

1
1

バージョン

言語

  • C++11

処理系

参照