ranges::basic_istream_view::iterator has an empty iterator_traitsSection: 25.6.6.3 [range.istream.iterator] Status: NAD Submitter: Patrick Palka Opened: 2020-02-09 Last modified: 2020-11-09
Priority: 2
View all other issues in [range.istream.iterator].
View all issues with NAD status.
Discussion:
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 becausebasic_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
24.3.2.3 [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.
[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.
[2020-02 Prioritized as P2 Monday morning in Prague]
Previous resolution [SUPERSEDED]:This wording is relative to N4849.
Modify 25.6.6.3 [range.istream.iterator], class template
basic_istream_view::iteratorsynopsis, 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; […] }; }
[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.
iterator_category member type of this template.
[2020-11-09 Status changed: Tentatively NAD → NAD.]
Proposed resolution: