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

履歴 編集

function
<ranges>

std::ranges::as_const_view::end(C++23)

constexpr auto end() requires (!simple-view<V>);    // (1)
constexpr auto end() const requires range<const V>; // (2)

概要

viewの番兵を取得する。

戻り値

入力viewV)のオブジェクトをbase_というメンバに保持するとして、(1)(2)どちらも

return ranges::cend(base_);

#include <ranges>
#include <vector>
#include <iostream>

int main() {
  std::vector<int> vec = {1, 2, 3, 4, 5};

  std::ranges::as_const_view acv{vec};

  auto it = acv.begin();
  auto se = acv.end();

  assert(it != se);

  --se;

  std::cout << *se << '\n'
}

出力

5

バージョン

言語

  • C++23

処理系

参照