Title
ranges::basic_istream_view::iterator has an empty iterator_traits
Status
nad
Section
[range.istream.iterator]
Submitter
Patrick Palka

Created on 2020-02-09.00:00:00 last changed 49 months ago

Messages

Date: 2020-11-09.00:00:00

[ 2020-11-09 Status changed: Tentatively NAD → NAD. ]

Date: 2020-02-15.00:00:00

[ 2020-02-13, Prague ]

LWG decided for NAD: The ranges::basic_istream_view::iterator is a move-only type and thus cannot meet the Cpp17 requirements (even output_iterator_tag), as such it should not specialize iterator_traits, to avoid misleading results when it is passed to new algorithms.

A related issue, LWG 3397, is supposed to take care for a problem with the definition of the iterator_category member type of this template.

Date: 2020-02-13.15:06:02

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

Previous resolution [SUPERSEDED]:

This wording is relative to N4849.

  1. Modify [range.istream.iterator], class template basic_istream_view::iterator synopsis, as indicated:

    namespace std::ranges {
      template<class Val, class CharT, class Traits>
      class basic_istream_view<Val, CharT, Traits>::iterator { // exposition only
      public:
        using iterator_category = input_iterator_tag;
        using difference_type = ptrdiff_t;
        using value_type = Val;
        using reference = Val&;
    
        iterator() = default;
        […]
      };
    }
    
Date: 2020-02-15.00:00:00

[ 2020-02-10; Jonathan comments ]

Jonathan and Casey have concerns about the proposed resolution. Casey: The wording makes it look as if this iterator is supposed to be an cpp17-input-iterator.

See also LWG 3283 and 3289.

Date: 2020-02-09.00:00:00

Every instantiation of ranges::basic_istream_view::iterator has an empty iterator_traits, i.e. the type

iterator_traits<ranges::basic_istream_view<Val, CharT, Traits>::iterator>

has no members.

This happens because basic_istream_view::iterator neither models cpp17-iterator (since this concept requires copyability, which this iterator is by design not) nor does it define all four of the member types difference_type, value_type, reference, and iterator_category (it is missing reference). Therefore by [iterator.traits] p3, this iterator's specialization of iterator_traits will be empty if generated from the iterator_traits primary template.

Since basic_istream_view::iterator is indeed an iterator, its iterator_traits should certainly not be empty. The simplest solution here is to define the member type reference in the definition of basic_istream_view::iterator, which will enable its iterator_traits specialization to be appropriately populated from the primary template.

History
Date User Action Args
2020-11-09 20:22:58adminsetmessages: + msg11536
2020-02-14 12:39:17adminsetstatus: new -> nad
2020-02-10 19:13:13adminsetmessages: + msg11028
2020-02-10 06:02:51adminsetmessages: + msg11007
2020-02-09 20:05:49adminsetmessages: + msg11006
2020-02-09 00:00:00admincreate