[Bug libstdc++/94674] std::ranges::basic_istream_view::iterator is missing std::iterator_traits entries

2020-04-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674

--- Comment #5 from Jonathan Wakely  ---
Your mistake is thinking that the iterators of views are like the iterators
you're used to.

They're not.

They have different properties (e.g. they might not be copyable, they might not
have operator->, they might not define iterator_category) and
std::iterator_traits is for use with the old kind of iterators, not the new
ones.

[Bug libstdc++/94674] std::ranges::basic_istream_view::iterator is missing std::iterator_traits entries

2020-04-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674

--- Comment #4 from Jonathan Wakely  ---
That iterator doesn't have a pointer type, because in the new Ranges world that
type is not useful. It is no longer required for iterators to have operator->
so what does the 'pointer' type even mean?

[Bug libstdc++/94674] std::ranges::basic_istream_view::iterator is missing std::iterator_traits entries

2020-04-20 Thread gcc-bugs at marehr dot dialup.fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674

--- Comment #3 from gcc-bugs at marehr dot dialup.fu-berlin.de ---
Thank you for pointing me to this.

I find this highly unexpected. There was made a change to `std::type_traits` in
C++20 that sets default values, but it does not apply to all iterators?

My use case was slightly different, I wanted to extract the `pointer` member
type and there is no equivalent like `std::ranges::range_pointer_t` for that.

This makes it particularly cumbersome to "forward" properties of an underlying
iterator which is used when wrapping it in a new iterator.

[Bug libstdc++/94674] std::ranges::basic_istream_view::iterator is missing std::iterator_traits entries

2020-04-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from Jonathan Wakely  ---
The current disposition of the Library Working Group is to leave it that way,
because it doesn't meet the traditional iterator requirements, so it's expected
that iterator_traits is empty for it.

As you already know, you can use range_value_t to get the value
type instead, and range_difference_t for the difference type, and use the
concepts std::input_iterator, std::forward_iterator etc. to determine which
concepts it satisfies. Code written to work with ranges should rely on those
interfaces, not iterator_traits, which is for traditional iterator types.

[Bug libstdc++/94674] std::ranges::basic_istream_view::iterator is missing std::iterator_traits entries

2020-04-20 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674

--- Comment #1 from Jonathan Wakely  ---
This is a known defect in the C++20 draft:
https://cplusplus.github.io/LWG/issue3394