- forward_list[meta header]
- std[meta namespace]
- forward_list[meta class]
- function[meta id-type]
- cpp11[meta cpp]
iterator end() noexcept; // (1) C++11
constexpr iterator end() noexcept; // (1) C++26
const_iterator end() const noexcept; // (2) C++11
constexpr const_iterator end() const noexcept; // (2) C++26末尾の次を指すイテレータを取得する。
末尾の次を指すイテレータ
投げない
- この関数によって返されるイテレータは、
*thisが保持するいずれの要素も参照しない。その指す先は、不正な範囲となるだろう
#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)::iterator last = ls.end();
decltype(ls)::const_iterator ci = cls.begin();
decltype(ls)::const_iterator clast = cls.end();
for (; i != last; ++i) {
std::cout << *i << std::endl;
}
for (; ci != clast; ++ci) {
std::cout << *ci << std::endl;
}
}- end()[color ff0000]
- begin()[link begin.md]
1
2
3
1
2
3
- C++11
- Clang: ??
- GCC: 4.7.0 [mark verified]
- ICC: ??
- Visual C++: 2010 [mark verified], 2012 [mark verified], 2013 [mark verified], 2015 [mark verified], 2017 [mark verified]