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
概要
要素数の近似値を取得する。
drop_viewは元のRangeから先頭 N 個を取り除くため、近似値は「元のRangeのreserve_hint − N」(負になる場合は 0)となる。
テンプレートパラメータ制約
- (1) : 型
Vがapproximately_sized_rangeであること - (2) : 型
const Vがapproximately_sized_rangeであること
効果
以下と等価:
const auto s = static_cast<range_difference_t<V>>(ranges::reserve_hint(base_));
return to-unsigned-like(s < count_ ? 0 : s - count_);
バージョン
言語
- C++26
処理系
- Clang: 22 ❌
- GCC: 16.1 ❌
- Visual C++: 2026 Update 2 ❌