- iterator[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp14[meta cpp]
namespace std {
template <class C>
constexpr auto cend(const C& c)
noexcept(noexcept(std::end(c)))
-> decltype(std::end(c));
}
- std::end[link end.md]
範囲から、最後尾要素の次を指す読み取り専用イテレータを取得する。
return std::end(c);
パラメータをconst
で受け取っているので、std::end()
を経由することで、読み取り専用イテレータを取得している。
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm> // for_each
int main()
{
std::vector<int> v = {1, 2, 3};
decltype(v)::const_iterator first = std::cbegin(v);
decltype(v)::const_iterator last = std::cend(v);
std::for_each(first, last, [](const int& x) {
std::cout << x << std::endl;
});
}
- std::cend[color ff0000]
- std::cbegin[link cbegin.md]
1
2
3
- C++14
- Clang: 3.4 [mark verified]
- GCC: 5.0 [mark verified]
- ICC: ??
- Visual C++: ??