Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:LegacyInputIterator

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      ALegacyInputIterator is aLegacyIterator that can read from the pointed-to element.LegacyInputIterators only guarantee validity for single pass algorithms: once aLegacyInputIteratori has been incremented, all copies of its previous value may be invalidated.

      Contents

      [edit]Requirements

      Type Definition
      X An input iterator type
      T Thevalue type ofX (i.e.std::iterator_traits<X>::value_type)
      Rstd::iterator_traits<X>::reference
      Value Definition
      i,j Values of typeX orconst X
      r A value of typeX&
      Other Definition
      m An identifier which possibly denotes a data member or member function


      X satisfiesLegacyInputIterator if all following conditions are satisfied:

       Expression TypeSemantics
      i!= j
      a type satisfyingBooleanTestable(until C++20)
      a type modelingboolean-testable(since C++20)
      Preconditioni andj are in thedomain of==.
      EffectEquivalent to!(i== j).
      *iR, convertible toTPreconditioni isdereferenceable.
      Effect
      • The expression(void)*i,*i is equivalent to*i.
      • Ifi andj are in the domain of==, andi== j, then*i is equivalent to*j.
      i->mPreconditioni is dereferenceable.
      EffectEquivalent to(*i).m.
      ++rX&Preconditionr is dereferenceable.
      Postcondition 
      • r is dereferenceable orr is past-the-end.
      • Any copies of the previous value ofr are no longer required to be either dereferenceable or to be in the domain of==.
      (void)r++EffectEquivalent to(void)++r.
      *r++convertible toTEffectEquivalent toT x=*r;++r;return x;.

      [edit]Equality domain

      The termthe domain of== is used in the ordinary mathematical sense to denote the set of values which can be compared using==. This set can change over time.

      Each algorithm places additional requirements on the equality domain for the iterator values it uses. These requirements can be inferred from the uses that algorithm makes of== and!=.

      [edit]Notes

      For an input iteratorX that is not aLegacyForwardIterator,std::iterator_traits<X>::reference does not have to be a reference type: dereferencing an input iterator may return a proxy object orstd::iterator_traits<X>::value_type itself by value (as in the case ofstd::istreambuf_iterator).

      Concept

      For the definition ofstd::iterator_traits, the following exposition-only concept is defined.

      template<class I>

      concept __LegacyInputIterator=
      __LegacyIterator<I>&&std::equality_comparable<I>&& requires(I i)
      {
         typenamestd::incrementable_traits<I>::difference_type;
         typenamestd::indirectly_readable_traits<I>::value_type;
         typenamestd::common_reference_t<std::iter_reference_t<I>&&,
                                           typenamestd::indirectly_readable_traits<I>::value_type&>;
         *i++;
         typenamestd::common_reference_t<decltype(*i++)&&,
                                           typenamestd::indirectly_readable_traits<I>::value_type&>;
          requiresstd::signed_integral<typenamestd::incrementable_traits<I>::difference_type>;

      };

      where the exposition-only concept__LegacyIterator is described inLegacyIterator.

      (since C++20)

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 98C++98the return type of*i++ was required to beTit can be any type convertible toT
      LWG 2114
      (P2167R3)
      C++98convertibility tobool was too weak to
      reflect the expectation of implementations
      requirements strengthened

      [edit]See also

      specifies that a type is an input iterator, that is, its referenced values can be read and it can be both pre- and post-incremented
      (concept)[edit]
      Iterator library provides definitions for iterators, iterator traits, adaptors, and utility functions
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/InputIterator&oldid=177457"

      [8]ページ先頭

      ©2009-2025 Movatter.jp