<div dir="ltr"><div dir="ltr">On Tue, 26 May 2020 at 07:39, Ray Lischner via cfe-users <<a href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</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/15/20 6:53 PM, Richard Smith wrote:<br>
> Can you try calling begin() on an istream_view<int>& directly, and see <br>
> if you get the same error?<br>
<br>
$ cat istream_begin.cpp<br>
#include <cassert><br>
#include <iostream><br>
#include <ranges><br>
#include <sstream><br>
<br>
int main()<br>
{<br>
auto ints = std::istringstream{"0 1 2 3 4"};<br>
auto view{ std::ranges::istream_view<int>(ints) };<br>
auto begin{ std::ranges::begin(view) };<br></blockquote><div><br></div><div>Here, Clang claims istream_view<int> has no member named 'begin', during satisfaction checking.</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">
assert(&*view.begin() == &*begin);<br></blockquote><div><br></div><div>... but Clang accepts this. There's definitely something wrong here.</div><div><br></div><div>Can you humor me for a second and try calling 'view.begin()' directly before using std::ranges::begin? (I'm suspicious that we're somehow not triggering instantiation of istream_view<int> until too late; calling 'view.begin()' earlier would resolve the problem if that's the case.)</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">
}<br>
$ g++ -std=c++20 istream_begin.cpp<br>
$ ./a.out<br>
$ clang++ -std=c++20 istream_begin.cpp<br>
In file included from istream_begin.cpp:2:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/iostream:39:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ostream:38:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ios:40:<br>
In file included from <br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/char_traits.h:39:<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:902: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>
istream_begin.cpp:9:14: note: in instantiation of template class <br>
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >' <br>
requested here<br>
auto view{ std::ranges::istream_view<int>(ints) };<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885: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:883: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:883: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:867: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:883: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:877: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>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902: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>
istream_begin.cpp:9:14: note: in instantiation of template class <br>
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >' <br>
requested here<br>
auto view{ std::ranges::istream_view<int>(ints) };<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885: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:883: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:883: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:867: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:883: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:877: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 istream_begin.cpp:3:<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>
istream_begin.cpp:9:14: note: in instantiation of template class <br>
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >' <br>
requested here<br>
auto view{ std::ranges::istream_view<int>(ints) };<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 istream_begin.cpp:3:<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>
istream_begin.cpp:10:15: error: no matching function for call to object <br>
of type 'const __cust_access::_Begin'<br>
auto begin{ std::ranges::begin(view) };<br>
^~~~~~~~~~~~~~~~~~<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:400:2: <br>
note: candidate template ignored: constraints not satisfied [with _Tp = <br>
std::ranges::basic_istream_view<int, char, std::char_traits<char> > &]<br>
operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>())<br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:397:11: <br>
note: because <br>
'is_array_v<remove_reference_t<std::ranges::basic_istream_view<int, <br>
char, std::char_traits<char> > &> >' evaluated to false<br>
requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:397:50: <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<remove_reference_t<_Tp>> || __member_begin<_Tp><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867: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/range_access.h:398:7: <br>
note: and 'std::ranges::basic_istream_view<int, char, <br>
std::char_traits<char> > &' does not satisfy '__adl_begin'<br>
|| __adl_begin<_Tp><br>
^<br>
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877: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>
5 errors generated.<br>
<br>
-- <br>
Ray Lischner<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div></div>