- span[meta header]
- std[meta namespace]
- span[meta class]
- function[meta id-type]
- cpp23[meta cpp]
constexpr const_iterator cend() const noexcept;
- const_iterator[link /reference/iterator/const_iterator.md]
末尾要素の次を指すイテレータを取得する。
return end();
- end[link ./end.md]
投げない
#include <iostream>
#include <span>
#include <vector>
template<typename I, std::sentinel_for<I> S>
bool is_iter_pair(I, S) {
return true;
}
bool is_iter_pair(...) {
return false;
}
int main() {
std::vector<int> v = {1, 2, 3, 4, 5};
std::span<int, 5> sp{v};
auto cit = sp.cend();
--cit;
std::cout << *cit << '\n';
std::cout << std::boolalpha;
std::cout << is_iter_pair(sp.cbegin(), sp.cend()) << '\n';
std::cout << is_iter_pair(sp.begin(), sp.cend()) << '\n';
}
- cend()[color ff0000]
- sentinel_for[link /reference/iterator/sentinel_for.md]
5
true
true
- C++23
- Clang: ??
- GCC: 13.1 [mark verified]
- Visual C++: 2022 Update 6 [mark verified]