Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::ranges::advance

      From cppreference.com
      <cpp‎ |experimental‎ |ranges
       
       
       
       
      Iterators library
      Iterator concepts
      Indirect callable concepts
                                                        
                                                        
                                                        
      Common algorithm requirements
                                                        
      Concept utilities
      Iterator utilities and operations
      advance
      Iterator traits
      Iterator adaptors
      Stream iterators
       
      namespace{

         constexpr/* unspecified */ advance=/* unspecified */;

      }
      (ranges TS)
      (customization point object)
      Call signature
      template< Iterator I>
      constexprvoid advance( I& i, ranges::difference_type_t<I> n);
      (1)
      template< Iterator I, Sentinel<I> S>
      constexprvoid advance( I& i, S bound);
      (2)
      template< Iterator I, Sentinel<I> S>
      constexpr ranges::difference_type_t<I> advance( I& i, ranges::difference_type_t<I> n, S bound);
      (3)

      Advances the iteratorin times, or untilbound is reached, whichever comes first.

      1) IfI modelsRandomAccessIterator, equivalent toi+= n. Otherwise, increments (or decrements ifn is negative)in times. The behavior is undefined ifn is negative andI does not modelBidirectionalIterator.
      2) IfAssignable<I&, S> is satisfied, equivalent toi= std::move(bound).
      Otherwise, if[ibound) does not denote a range, the behavior is undefined.
      Otherwise, ifSizedSentinel<S, I> is satisfied, equivalent toranges::advance(i, bound- i).
      Otherwise, incrementsi untili== bound.
      3) IfSizedSentinel<S, I> is satisfied, equivalent toranges::advance(i, bound) if |n| >= |bound- i|, andranges::advance(i, n) otherwise.
      Otherwise, increments (or decrements ifn is negative)i eithern times or untili== bound, whichever comes first.
      Ifn>0,[ibound) shall denote a range; ifn==0, either[ibound) or[boundi) shall denote a range; ifn<0,[boundi) shall denote a range,I andS shall be the same type, andI must modelBidirectionalIterator. Otherwise, the behavior is undefined.

      Contents

      [edit] Customization point objects

      The nameranges::advance denotes acustomization point object, which is afunction object of aliteralSemiregular class type (denoted, for exposition purposes, asAdvanceT). All instances ofAdvanceT are equal. Thus,ranges::advance can be copied freely and its copies can be used interchangeably.

      Given a set of typesArgs..., ifstd::declval<Args>()... meet the requirements for arguments toranges::advance above,AdvanceT will satisfyranges::Invocable<const AdvanceT, Args...>. Otherwise, no function call operator ofAdvanceT participates in overload resolution.

      In every translation unit in whichranges::advance is defined, it refers to the same instance of the customization point object. (This means that it can be used freely in things like inline functions and function templates without violating theone-definition rule.)

      [edit]Return value

      1,2) (none)
      3) The number of increment/decrements not performed due to reachingbound. In other words,n- M, whereM is the distance from the starting position ofi to the ending position and is negative if the ending position is before the starting position.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      advances an iterator by given distance
      (function template)[edit]
      returns the distance between an iterator and a sentinel, or between the beginning and the end of a range
      (function template)[edit]
      increment an iterator
      (function template)[edit]
      decrement an iterator
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/ranges/iterator/advance&oldid=157770"

      [8]ページ先頭

      ©2009-2026 Movatter.jp