This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

1011. next/prev wrong iterator type

Section: 25.4.3 [iterator.operations] Status: C++11 Submitter: Alisdair Meredith Opened: 2009-03-11 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [iterator.operations].

View all other issues in [iterator.operations].

View all issues with C++11 status.

Discussion:

Addresses UK 271

next/prev return an incremented iterator without changing the value of the original iterator. However, even this may invalidate an InputIterator. A ForwardIterator is required to guarantee the 'multipass' property.

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

[ 2009-07 Frankfurt ]

Moved from Tentatively Ready to Open only because the wording needs to be tweaked for concepts removal.

[ 2009-10-14 Daniel provided de-conceptified wording. ]

[ 2009-10 Santa Cruz: ]

Moved to Ready.

Proposed resolution:

  1. Change header <iterator> synopsis 25.2 [iterator.synopsis] as indicated:

    // 24.4.4, iterator operations:
    ...
    template <class InputForwardIterator>
      InputForwardIterator
      next(InputForwardIterator x, typename std::iterator_traits<InputForwardIterator>::difference_type n = 1);
    
  2. Change 25.4.3 [iterator.operations] before p.6 as indicated:

    template <class InputForwardIterator>
      InputForwardIterator
      next(InputForwardIterator x, typename std::iterator_traits<InputForwardIterator>::difference_type n = 1);