• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <ranges>

    std::ranges::filter_view::iterator::operator++

    constexpr iterator& operator++();                             // (1)
    constexpr void operator++(int);                               // (2)
    constexpr iterator operator++(int) requires forward_range<V>; // (3)
    

    概要

    イテレータを1つ進める。

    効果

    (1)は、

    current_ = ranges::find_if(
      std::move(++current_),
      ranges::end(parent_->base_),
      ref(*parent_->pred_));
    return *this;
    

    と等しい。

    (2)は、++*this と等しい。

    (3)は、

    auto tmp = *this;
    ++*this;
    return tmp;
    

    と等しい。

    #include <ranges>
    #include <vector>
    
    int main() {
      using std::ranges::filter_view;
      using std::ranges::iterator_t;
    
      std::vector<int> vec = {0, 1, 2, 3, 4, 5};
    
      filter_view fv{vec, [](int x){ return x % 2 == 0; }};
    
      iterator_t<filter_view> i(fv, vec.begin());
    
      std::cout << *i << `\n`;
      i++;
      std::cout << *i << `\n`;
      i++;
      std::cout << *i << `\n`;
    }
    

    出力

    0
    2
    4
    

    バージョン

    言語

    • C++20

    処理系

    参照