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

3385. common_iterator is not sufficiently constrained for non-copyable iterators

Section: 25.5.5.1 [common.iterator] Status: C++20 Submitter: Corentin Jabot Opened: 2020-01-31 Last modified: 2021-02-25

Priority: 0

View all other issues in [common.iterator].

View all issues with C++20 status.

Discussion:

We don't actually specify anywhere that non-copyable iterators do not have a common_iterator (and it would make little sense for them to as algorithms dealing with C++17 iterators are not expecting non-copyable things) As it stands common_iterator can be created from move only iterator but are then non-copyable themselves. P1862 already constrains common_view in a similar fashion

[2020-02 Prioritized as IMMEDIATE Monday morning in Prague]

Proposed resolution:

This wording is relative to N4849.

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

    namespace std {
      […]
      // 25.5.5 [iterators.common], common iterators
      template<input_or_output_iterator I, sentinel_for<I> S>
        requires (!same_as<I, S> && copyable<I>)
          class common_iterator;
      […]
    }
    
  2. Modify 25.5.5.1 [common.iterator], class template common_iterator synopsis, as indicated:

    namespace std {
      template<input_or_output_iterator I, sentinel_for<I> S>
        requires (!same_as<I, S> && copyable<I>)
      class common_iterator {
      public:
        […]
      };
      […]
    }