[Bug c++/96704] begin() and end() iterators of views::values_view have different type

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 19 11:24:16 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96704

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Right, it's incorrect to assume begin and end return the same type for a range.

Use std::common_iterator if you need to turn an iterator and its sentinel into
a single type:

  using CI = std::common_iterator<decltype(r.begin()), decltype(r.end())>;
  foo(CI(r.begin()), CI(r.end()));


More information about the Gcc-bugs mailing list