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

履歴 編集

function
<ranges>

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

constexpr auto end()
  requires (!simple-view<V>);       // (1) C++20

constexpr auto end() const
  requires range<const V> &&
           indirect_unary_predicate<
             const Pred,
             iterator_t<const V>
           >;                        // (2) C++20

概要

番兵を取得する。

戻り値

  • (1), (2) : 以下と等価:
    return ranges::end(base_);
    

ただし、base_は元のviewを表すメンバ変数。

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

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

  std::ranges::drop_while_view r{vec, [](int x) { return x < 6; }};

  auto it = r.begin();
  auto end_it = r.end();
  while (it != end_it) {
    int x = *it;
    std::cout << x << " ";
    ++it;
  }
  std::cout << std::endl;
}

出力

6 7 8 9 10 

バージョン

言語

  • C++20

処理系