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

履歴 編集

function
<ranges>

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

constexpr auto end() {
  if constexpr (common_range<V>)
    return iterator{*this, ranges::end(base_)};
  else
    return sentinel{*this};
}

概要

番兵を取得する。

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

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

  std::ranges::filter_view fv{vec, [](int i) { return i % 2 == 0; }};

  auto e = fv.end();

  --e;

  std::cout << *e << '\n';
}

出力

4

バージョン

言語

  • C++20

処理系

参照