<div dir="ltr"><div>fixed example code:</div><div>--</div><div>#include <algorithm><br>#include <cstdio><br>#include <ranges><br>#include <string><br> <br>char rot13a(const char x, const char a)<br>{<br>    return a + (((x - a) + 13) % 26);<br>}<br><br>char rot13(const char x)<br>{<br>   if (x >= 'A' && x <= 'Z') {<br>             return rot13a(x, 'A');<br>        }<br><br>   if (x >= 'a' && x <= 'z') {<br>             return rot13a(x, 'a');<br>        }<br><br>   return x;<br>}<br> <br>int main()<br>{<br>    auto show = [](const char x) { std::putchar(x); };<br> <br>    std::string in{ "<a href="http://cppreference.com">cppreference.com</a>\n" };<br>    std::ranges::for_each(in, show);<br>    std::ranges::for_each(in | std::views::transform(rot13), show);<br> <br>    std::string out;<br>    std::ranges::copy( std::views::transform(in, rot13), std::back_inserter(out) );<br>    std::ranges::for_each(out, show);<br>    std::ranges::for_each(out | std::views::transform(rot13), show);<br>}<br></div><div><br></div><div>errors:</div><div>--</div><div>In file included from tmp.cpp:1:<br>In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/algorithm:61:<br>In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_algobase.h:65:<br>In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_iterator_base_types.h:71:<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:980:13: fatal error: no matching function for call to '__begin'<br>        = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>()));<br>                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/ranges_base.h:586:5: note: in instantiation of template type alias '__range_iter_t' requested here<br>    using iterator_t = std::__detail::__range_iter_t<_Tp>;<br>    ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/ranges_util.h:98:43: note: in instantiation of template type alias 'iterator_t' requested here<br>      data() requires contiguous_iterator<iterator_t<_Derived>><br>                                          ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:1014:29: note: in instantiation of template class 'std::ranges::view_interface<std::ranges::ref_view<std::basic_string<char>>>' requested here<br>    class ref_view : public view_interface<ref_view<_Range>><br>                            ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:1070:38: note: in instantiation of template class 'std::ranges::ref_view<std::basic_string<char>>' requested here<br>        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };<br>                                            ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:1070:38: note: in instantiation of requirement here<br>        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };<br>                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:1070:27: note: (skipping 20 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)<br>        concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; };<br>                                 ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:748:9: note: while substituting template arguments into constraint expression here<br>      = requires { std::declval<_Adaptor>()(declval<_Args>()...); };<br>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:773:5: note: while checking the satisfaction of concept '__adaptor_invocable<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, char (*)(char)>, std::basic_string<char> &>' requested here<br>        && __adaptor_invocable<_Self, _Range><br>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/ranges:773:5: note: while substituting template arguments into constraint expression here<br>        && __adaptor_invocable<_Self, _Range><br>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>tmp.cpp:30:30: note: while checking constraint satisfaction for template 'operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, char (*)(char)>, std::basic_string<char> &>' required here<br>    std::ranges::for_each(in | std::views::transform(rot13), show);<br>                             ^<br>tmp.cpp:30:30: note: in instantiation of function template specialization 'std::ranges::views::__adaptor::operator|<std::ranges::views::__adaptor::_Partial<std::ranges::views::_Transform, char (*)(char)>, std::basic_string<char> &>' requested here<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:964:7: note: candidate template ignored: constraints not satisfied [with _Tp = std::ranges::ref_view<std::basic_string<char>>]<br>      __begin(_Tp& __t)<br>      ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:962:16: note: because 'is_array_v<std::ranges::ref_view<std::basic_string<char> > >' evaluated to false<br>      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>               ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:962:35: note: and 'std::ranges::ref_view<std::basic_string<char>> &' does not satisfy '__member_begin'<br>      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>                                  ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:945:23: note: because '__decay_copy(__t.begin())' would be invalid: no member named 'begin' in 'std::ranges::ref_view<std::basic_string<char>>'<br>          { __decay_copy(__t.begin()) } -> input_or_output_iterator;<br>                             ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:962:59: note: and 'std::ranges::ref_view<std::basic_string<char>> &' does not satisfy '__adl_begin'<br>      requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>                                                          ^<br>/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/iterator_concepts.h:956:19: note: because '__decay_copy(begin(__t))' would be invalid: call to deleted function 'begin'<br>          { __decay_copy(begin(__t)) } -> input_or_output_iterator;<br>                         ^<br>1 error generated.<br><br>shell returned 1<br></div></div>