GeezerVison is showing cpprefjp.github.io — std::array::end - cpprefjp C++日本語リファレンス
最終更新日時:
2026年09月19日 21時31分51秒 (JST)
rotarymars
が更新
履歴
編集
function
<array>
std:: array:: end (C++11)
iterator end () noexcept ; // (1) C++11
constexpr iterator end () noexcept ; // (1) C++17
const_iterator end () const noexcept ; // (2) C++11
constexpr const_iterator end () const noexcept ; // (2) C++17
概要
末尾の次を指すイテレータを取得する。
戻り値
非constな文脈ではiterator型で最後尾要素の次を指すイテレータを返し、
constな文脈ではconst_iterator型で 最後尾要素の次を指すイテレータを返す。
例外
投げない
計算量
定数時間
備考
この関数によって返されるイテレータは、*thisが保持するいずれの要素も参照しない。その指す先は、不正な範囲となるだろう
例
#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 ) :: iterator last = ar . end ();
decltype ( ar ) :: const_iterator ci = car . begin ();
decltype ( ar ) :: const_iterator clast = car . end ();
for (; i != last ; ++ i ) {
std::cout << * i << std::endl ;
}
for (; ci != clast ; ++ ci ) {
std::cout << * ci << std::endl ;
}
}
出力
1
2
3
1
2
3
バージョン
言語
処理系
参照