constexpr auto reserve_hint()
requires approximately_sized_range<V>; // (1) C++26
constexpr auto reserve_hint() const
requires approximately_sized_range<const V>; // (2) C++26
概要
要素数の推定値(確保のヒント)を取得する。
効果
- (1), (2) : 以下と等価:
return ranges::reserve_hint(base_);
例
#include <ranges>
#include <vector>
#include <print>
int main() {
std::vector<int> v = {1, 2, 3, 4, 5};
std::ranges::cache_latest_view view{v};
std::println("{}", view.reserve_hint());
}
出力
5
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌