<div dir="ltr"><div dir="ltr">On Thu, 14 May 2020 at 03:50, Ray Lischner <<a href="mailto:ray@klipp-lischner.net">ray@klipp-lischner.net</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 5/13/20 10:09 PM, Richard Smith wrote:<br>
> On Wed, 6 May 2020 at 09:24, Ray Lischner via cfe-users <br>
> <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a> <mailto:<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>>> wrote:<br>
> <br>
> I am using clang++ 10 with GCC libstdc++ 10 prerelease. I tried<br>
> compiling the example from section 24.6.4.1<br>
> [range.istream.overview]. It<br>
> works with g++ 10 but with clang++ 10 -std=c++20, I get<br>
> constraint-failure errors.<br>
> <br>
> program:<br>
> #include <algorithm><br>
> #include <iostream><br>
> #include <iterator><br>
> #include <ranges><br>
> #include <sstream><br>
> <br>
> int main()<br>
> {<br>
> using namespace std;<br>
> using namespace ranges;<br>
> auto ints = istringstream{"0 1 2 3 4"};<br>
> ranges::copy(istream_view<int>(ints),<br>
> ostream_iterator<int>{cout, "-"});<br>
> // prints0-1-2-3-4-<br>
> }<br>
> <br>
> $ clang++ -std=c++20 -o range_istream_overview \<br>
> range_istream_overview.cpp<br>
> <br>
> Gist of the errors is that the istream_view fails the constraints for a<br>
> range because ranges::begin() fails its constraint for the<br>
> basic_istream_view::begin() member function:<br>
> <br>
> { __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator;<br>
> <br>
> Any ideas what's wrong or how to proceed?<br>
> <br>
> <br>
> Please could you provide the complete set of diagnostics from the <br>
> compilation?<br>
<br>
In file included from range_istream_overview.cpp:1:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/algorithm:61:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_algobase.h:65:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:71:<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:884:13: <br>
error: no matching function for call to '__ranges_begin'<br>
= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));<br>
^~~~~~~~~~~~~~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: <br>
note: in instantiation of template type alias '__range_iter_t' requested <br>
here<br>
using iterator_t = std::__detail::__range_iter_t<_Tp>;<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:134:43: <br>
note: in instantiation of template type alias 'iterator_t' requested here<br>
data() requires contiguous_iterator<iterator_t<_Derived>><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14: <br>
note: in instantiation of template class <br>
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > >' requested here<br>
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>><br>
^<br>
range_istream_overview.cpp:12:16: note: in instantiation of template <br>
class 'std::ranges::basic_istream_view<int, char, std::char_traits<char> <br>
>' requested here<br>
ranges::copy(istream_view<int>(ints), ostream_iterator<int>{cout, "-"});<br>
^<br></blockquote><div><br></div><div>OK, so the relevant part is this:</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:7: <br>
note: candidate template ignored: constraints not satisfied [with _Tp = <br>
std::ranges::basic_istream_view<int, char, std::char_traits<char> >]<br>
__ranges_begin(_Tp& __t)<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:16: <br>
note: because 'is_array_v<std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > >' evaluated to false<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:35: <br>
note: and 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > &' does not satisfy '__member_begin'<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:849:33: <br>
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no <br>
member named 'begin' in 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >'<br>
{ __detail::__decay_copy(__t.begin()) } -> <br>
input_or_output_iterator;<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:59: <br>
note: and 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > &' does not satisfy '__adl_begin'<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:859:29: <br>
note: because '__detail::__decay_copy(begin(__t))' would be invalid: <br>
call to deleted function 'begin'<br>
{ __detail::__decay_copy(begin(__t)) } -> <br>
input_or_output_iterator;<br>
^<br></blockquote><div><br></div><div>Just as you said, it looks like the problem is that __member_begin<istream_view<int>&> is evaluating to 'false', whereas it presumably should evaluate to 'true'.</div><div><br></div><div>Can you try calling begin() on an istream_view<int>& directly, and see if you get the same error?</div><div><br></div><div>A heavily-reduced testcase doesn't demonstrate the problem -- <a href="https://godbolt.org/z/Np4EMg">https://godbolt.org/z/Np4EMg</a> -- so I imagine there's something else required to trigger this behavior. A more-reduced testcase should make the problem easier to understand.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:884:13: <br>
error: no matching function for call to '__ranges_begin'<br>
= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));<br>
^~~~~~~~~~~~~~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5: <br>
note: in instantiation of template type alias '__range_iter_t' requested <br>
here<br>
using iterator_t = std::__detail::__range_iter_t<_Tp>;<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:140:25: <br>
note: in instantiation of template type alias 'iterator_t' requested here<br>
&& contiguous_iterator<iterator_t<const _Derived>><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14: <br>
note: in instantiation of template class <br>
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > >' requested here<br>
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>><br>
^<br>
range_istream_overview.cpp:12:16: note: in instantiation of template <br>
class 'std::ranges::basic_istream_view<int, char, std::char_traits<char> <br>
>' requested here<br>
ranges::copy(istream_view<int>(ints), ostream_iterator<int>{cout, "-"});<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:7: <br>
note: candidate template ignored: constraints not satisfied [with _Tp = <br>
const std::ranges::basic_istream_view<int, char, std::char_traits<char> >]<br>
__ranges_begin(_Tp& __t)<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:16: <br>
note: because 'is_array_v<const std::ranges::basic_istream_view<int, <br>
char, std::char_traits<char> > >' evaluated to false<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:35: <br>
note: and 'const std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > &' does not satisfy '__member_begin'<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:849:33: <br>
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no <br>
member named 'begin' in 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >'<br>
{ __detail::__decay_copy(__t.begin()) } -> <br>
input_or_output_iterator;<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:865:59: <br>
note: and 'const std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > &' does not satisfy '__adl_begin'<br>
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:859:29: <br>
note: because '__detail::__decay_copy(begin(__t))' would be invalid: <br>
call to deleted function 'begin'<br>
{ __detail::__decay_copy(begin(__t)) } -> <br>
input_or_output_iterator;<br>
^<br>
In file included from range_istream_overview.cpp:1:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/algorithm:64:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algo.h:35:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algobase.h:38:<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:146:24: <br>
error: constraints not satisfied for alias template 'sentinel_t' [with <br>
_Range = std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >]<br>
&& sized_sentinel_for<sentinel_t<_Derived>, iterator_t<_Derived>><br>
^~~~~~~~~~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14: <br>
note: in instantiation of template class <br>
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > >' requested here<br>
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>><br>
^<br>
range_istream_overview.cpp:12:16: note: in instantiation of template <br>
class 'std::ranges::basic_istream_view<int, char, std::char_traits<char> <br>
>' requested here<br>
ranges::copy(istream_view<int>(ints), ostream_iterator<int>{cout, "-"});<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:876:12: <br>
note: because 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >' does not satisfy 'range'<br>
template<range _Range><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:864:2: <br>
note: because 'ranges::begin(__t)' would be invalid: no matching <br>
function for call to object of type 'const __cust_access::_Begin'<br>
ranges::begin(__t);<br>
^<br>
In file included from range_istream_overview.cpp:1:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/algorithm:64:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algo.h:35:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algobase.h:38:<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:152:24: <br>
error: constraints not satisfied for alias template 'sentinel_t' [with <br>
_Range = const std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >]<br>
&& sized_sentinel_for<sentinel_t<const _Derived>,<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:876:12: <br>
note: because 'const std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >' does not satisfy 'range'<br>
template<range _Range><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:864:2: <br>
note: because 'ranges::begin(__t)' would be invalid: no matching <br>
function for call to object of type 'const __cust_access::_Begin'<br>
ranges::begin(__t);<br>
^<br>
range_istream_overview.cpp:12:3: error: no matching function for call to <br>
object of type 'const std::ranges::__copy_fn'<br>
ranges::copy(istream_view<int>(ints), ostream_iterator<int>{cout, "-"});<br>
^~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algobase.h:309:7: <br>
note: candidate template ignored: substitution failure [with _Range = <br>
std::ranges::basic_istream_view<int, char, std::char_traits<char> >, <br>
_Out = std::ostream_iterator<int, char, std::char_traits<char> >]: <br>
constraints not satisfied for alias template 'borrowed_iterator_t' [with <br>
_Range = std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> >]<br>
operator()(_Range&& __r, _Out __result) const<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/ranges_algobase.h:299:7: <br>
note: candidate function template not viable: requires 3 arguments, but <br>
2 were provided<br>
operator()(_Iter __first, _Sent __last, _Out __result) const<br>
^<br>
5 errors generated.<br>
<br>
-- <br>
Ray Lischner<br>
</blockquote></div></div>