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

履歴 編集

function
<ranges>

std::ranges::owning_view::end(C++20)

constexpr sentinel_t<R> end(); // (1) C++20

constexpr auto end() const
  requires range<const R>;     // (2) C++20

概要

番兵を取得する。

効果

  • (1) : return ranges::end(r_);
  • (2) : return ranges::end(r_);

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

int main() {
  std::vector<int> v = {1, 2, 3, 4, 5};
  std::ranges::owning_view ov{std::move(v)};

  // イテレータ範囲で全要素を出力
  for (auto it = ov.begin(); it != ov.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

出力

1 2 3 4 5 

バージョン

言語

  • C++20

処理系

参照