iterator begin() noexcept; // (1) C++26
const_iterator begin() const noexcept; // (2) C++26
概要
先頭要素を指すイテレータを取得する。
戻り値
先頭要素を指すイテレータ
例外
投げない
計算量
定数時間
例
#include <hive>
#include <print>
int main()
{
std::hive<int> h;
h.insert(1);
h.insert(2);
h.insert(3);
const std::hive<int>& ch = h;
decltype(h)::iterator i = h.begin(); // (1)
decltype(h)::const_iterator ci = ch.begin(); // (2)
// begin()からend()まで走査する
for (auto it = i; it != h.end(); ++it) {
std::print("{} ", *it);
}
std::println("");
std::println("{}", *ci);
}
出力例
1 2 3
1
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌