- span[meta header]
- std[meta namespace]
- span[meta class]
- function[meta id-type]
- cpp23[meta cpp]
constexpr const_iterator cbegin() const noexcept;
- const_iterator[link /reference/iterator/const_iterator.md]
先頭要素を指す読み取り専用イテレータを取得する。
return begin();
- begin[link ./begin.md]
投げない
#include <iostream>
#include <span>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 3, 4, 5};
std::span<int, 5> sp{v};
auto cit = sp.cbegin();
std::cout << *cit << '\n';
// これはできない
// *cit = 0;
}
- cbegin()[color ff0000]
1
- C++23
- Clang: ??
- GCC: 13.1
- Visual C++: 2022 Update 6