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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think this is a bug (and it's definitely not a compiler crash, it's
just an error and failure to compile - there's no crash).

The return type of std::ranges::cbegin(someString) is:

   std::string::const_iterator

The type std::ranges::const_iterator_t<std::string> is:

   std::basic_const_iterator<std::string::iterator>

Those are not related types, you cannot convert one to the other.

The type std::ranges::const_iterator_t<std::string> is:

   std::basic_const_iterator<std::string::const_iterator>

and you can convert std::string::const_iterator to that type. That's why it
works when you add const to the const_iterator_t template argument (you don't
need to make someString const for that to work).


What are you actually trying to do here? Maybe you want to use views::as_const?

   some_function(std::ranges::cbegin(someString | std::views::as_const));

Reply via email to