Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ranges::filter_view<V,Pred>::iterator

      From cppreference.com
      <cpp‎ |ranges‎ |filter view
       
       
      Ranges library
      Range adaptors
       
       
      class/*iterator*/;
      (since C++20)
      (exposition only*)

      The return type offilter_view::begin.

      This is abidirectional_iterator ifV modelsbidirectional_range, aforward_iterator ifV modelsforward_range, andinput_iterator otherwise.

      Modification of the element denoted by this iterator is permitted, but results in undefined behavior if the resulting value does not satisfy the filter's predicate.

      Contents

      [edit]Member types

      Type Definition
      iterator_concept
      iterator_category
      (present only ifV models
      forward_range)

      LetC be the typestd::iterator_traits<ranges::iterator_t<V>>::iterator_category.

      value_typeranges::range_value_t<V>
      difference_typeranges::range_difference_t<V>

      [edit]Data members

      Member Description
      ranges::iterator_t<V>current_(private) an iterator into the underlyingview
      (exposition-only member object*)
      ranges::filter_view<V, Pred>*parent_(private) a pointer to the parentfilter_view object
      (exposition-only member object*)

      [edit]Member functions

      constructs an iterator
      (public member function)
      returns the underlying iterator
      (public member function)
      forwards to the underlying iterator
      (public member function)
      advances the iterator
      (public member function)
      decrements the iterator
      (public member function)

      std::ranges::filter_view::iterator::iterator

      /*iterator*/()
          requiresstd::default_initializable<ranges::iterator_t<V>>=default;
      (1)(since C++20)
      constexpr/*iterator*/( filter_view& parent,
                             ranges::iterator_t<V> current);
      (2)(since C++20)
      1) Initializescurrent_ andparent_ with their default member initializers, which are=ranges::iterator_t<V>() and= nullptr respectively.
      2) Initializescurrent_ withstd::move(current) andparent_ withstd::addressof(parent).

      std::ranges::filter_view::iterator::base

      constexprconstranges::iterator_t<V>& base()const&noexcept;
      (1)(since C++20)
      constexprranges::iterator_t<V> base()&&;
      (2)(since C++20)
      1) Equivalent toreturn current_;.
      2) Equivalent toreturn std::move(current_);.

      std::ranges::filter_view::iterator::operator*,->

      constexprranges::range_reference_t<V> operator*()const;
      (1)(since C++20)
      constexprranges::iterator_t<V> operator->()const

          requires/*has-arrow*/<ranges::iterator_t<V>>&&

                   std::copyable<ranges::iterator_t<V>>;
      (2)(since C++20)
      1) Equivalent toreturn*current_;.
      2) Equivalent toreturn current_;.

      For a typeI,/*has-arrow*/<I> is modeled or satisfied, if and only ifI models or satisfiesinput_iterator respectively, and eitherI is a pointer type orrequires(I i){ i.operator->();} istrue.

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

      constexpr/*iterator*/& operator++();
      (1)(since C++20)
      constexprvoid operator++(int);
      (2)(since C++20)
      constexpr/*iterator*/ operator++(int)
          requiresranges::forward_range<V>;
      (3)(since C++20)
      1) Equivalent to
      current_=ranges::find_if(std::move(++current_),ranges::end(parent_->base_),
                                 std::ref(*parent_->pred_));
      return*this;
      .
      2) Equivalent to++*this;.
      3) Equivalent toauto tmp=*this;++*this;return tmp;.

      std::ranges::filter_view::iterator::operator--

      constexpr/*iterator*/& operator--()
          requiresranges::bidirectional_range<V>;
      (1)(since C++20)
      constexpr/*iterator*/ operator--(int)
          requiresranges::bidirectional_range<V>;
      (2)(since C++20)
      1) Equivalent to
      do
         --current_;
      while(!std::invoke(*parent_->pred_,*current_));
      return*this;
      .
      2) Equivalent toauto tmp=*this;--*this;return tmp;.

      [edit]Non-member functions

      (C++20)
      compares the underlying iterators
      (function)
      (C++20)
      casts the result of dereferencing the underlying iterator to its associated rvalue reference type
      (function)
      (C++20)
      swaps the objects pointed to by two underlying iterators
      (function)

      operator==(std::ranges::filter_view::iterator)

      friendconstexprbool operator==(const/*iterator*/& x,const/*iterator*/& y)
          requiresstd::equality_comparable<ranges::iterator_t<V>>;
      (since C++20)

      Equivalent toreturn x.current_== y.current_;.

      The!= operator issynthesized fromoperator==.

      This function is not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup whenstd::ranges::filter_view::iterator is an associated class of the arguments.

      iter_move(std::ranges::filter_view::iterator)

      friendconstexprranges::range_rvalue_reference_t<V>

      iter_move(const/*iterator*/& i)

         noexcept(noexcept(ranges::iter_move(i.current_)));
      (since C++20)

      Equivalent toreturnranges::iter_move(i.current_);.

      This function is not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup whenstd::ranges::filter_view::iterator is an associated class of the arguments.

      iter_swap(std::ranges::filter_view::iterator)

      friendconstexprvoid iter_swap(const/*iterator*/& x,const/*iterator*/& y)

         noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))

              requiresstd::indirectly_swappable<ranges::iterator_t<V>>;
      (since C++20)

      Equivalent toranges::iter_swap(x.current_, y.current_).

      This function is not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup whenstd::ranges::filter_view::iterator is an associated class of the arguments.

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      P2259R1C++20member typeiterator_category was always defineddefined only ifV is aforward_range
      LWG 3533C++20theconst& overload ofbase copied the underlying iteratorreturns a reference to it
      LWG 3593C++20theconst& overload ofbase might not be noexceptmade noexcept
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/filter_view/iterator&oldid=181346"

      [8]ページ先頭

      ©2009-2025 Movatter.jp