最終更新日時(UTC):
が更新

履歴 編集

function
<ranges>

std::ranges::as_rvalue_view::base(C++23)

constexpr V base() const &
  requires copy_constructible<V>; // (1) C++23

constexpr V base() &&;            // (2) C++23

概要

元となるRangeを取得する。

  • (1) : 元となるRangeをコピーして返す
  • (2) : 元となるRangeをムーブして返す

戻り値

メンバ変数base_として保持している、元となるRangeオブジェクトがあるとして、以下を返す:

  • (1) :

    return base_;
    

  • (2) :

    return std::move(base_);
    

備考

#include <cassert>
#include <vector>
#include <ranges>

int main() {
  std::vector<int> v = {1, 2, 3};
  auto r = std::views::as_rvalue(v);
  std::ranges::ref_view<std::vector<int>> base = r.base();

  assert(&base.base() == &v);
}

出力

バージョン

言語

  • C++23

処理系