constexpr V base() const&
requires copy_constructible<V>; // (1) C++26
constexpr V base() &&; // (2) C++26
概要
メンバ変数として保持している、元のRangeを取得する。
効果
- (1) :
return base_; - (2) :
return std::move(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};
// (1) コピーして取得
auto v1 = view.base();
std::println("{}", v1.size());
}
出力
5
バージョン
言語
- C++26
処理系
- Clang: 21 ✅
- GCC: 15.1 ✅
- Visual C++: 2026 Update 2 ❌