Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:LegacyBidirectionalIterator

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

      ALegacyBidirectionalIterator is aLegacyForwardIterator that can be moved in both directions (i.e. incremented and decremented).

      If aLegacyBidirectionalIteratorit originates from aContainer, thenit'svalue_type is the same as the container's, so dereferencing (*it) obtains the container'svalue_type.

      Contents

      [edit]Requirements

      The typeIt satisfiesLegacyBidirectionalIterator if

      And, given

      The following expressions must be valid and have their specified effects:

      ExpressionReturnEquivalent expressionNotes
      --aIt&Preconditions:
      • a is decrementable (there exists suchb thata==++b)

      Postconditions:

      • a isdereferenceable
      • --(++a)== a
      • If--a==--b thena== b
      • a and--a designate the same iterator object
      a-- convertible toconst It&It temp= a;

      --a;

      return temp;
      *a--reference

      AmutableLegacyBidirectionalIterator is aLegacyBidirectionalIterator that additionally satisfies theLegacyOutputIterator requirements.

      [edit]Notes

      The begin iterator is not decrementable and the behavior is undefined if--container.begin() is evaluated.

      A bidirectional iterator does not have to be dereferenceable to be decrementable (in particular, the end iterator is not dereferenceable but is decrementable).

      Concept

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

      template<class I>

      concept __LegacyBidirectionalIterator=
          __LegacyForwardIterator<I>&& requires(I i)
         {
             {  --i}->std::same_as<I&>;
             {  i--}->std::convertible_to<const I&>;
             {*i--}->std::same_as<std::iter_reference_t<I>>;

         };

      where the exposition-only concept__LegacyForwardIterator is described inLegacyForwardIterator.

      (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 299
      (N3066)
      C++98the return type of*a-- was
      required to be convertible toT
      changed the return
      type toreference[1]
      LWG 383C++98b was required to be dereferenceable after--aa is required to be dereferenceable instead
      LWG 1212
      (N3066)
      C++98the return type of*a-- did not match the return
      type of*a++ required byLegacyForwardIterator
      changed the return
      type toreference
      1. This issue was initially resolved byN2758 (iterator concepts), which was dropped later from the C++ standard.

      [edit]See also

      specifies that aforward_iterator is a bidirectional iterator, supporting movement backwards
      (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/BidirectionalIterator&oldid=171804"

      [8]ページ先頭

      ©2009-2025 Movatter.jp