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

履歴 編集

function
<array>

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

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

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

概要

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

戻り値

constな文脈ではiterator型で先頭要素へのイテレータを返し、 constな文脈ではconst_iterator型で先頭要素へのイテレータを返す。

例外

投げない

計算量

定数時間

#include <iostream>
#include <array>

int main()
{
  std::array<int, 3> ar = {1, 2, 3};
  const std::array<int, 3>& car = ar;

  decltype(ar)::iterator i = ar.begin();
  decltype(ar)::const_iterator ci = car.begin();

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

出力

1
1

バージョン

言語

  • C++11

処理系

参照