[cfe-users] Compiling C++ 20 Example from 24.6.4.1 [range.istream.overview] produces errors with libstdc++ 10
Ray Lischner via cfe-users
cfe-users at lists.llvm.org
Tue May 26 07:38:12 PDT 2020
On 5/15/20 6:53 PM, Richard Smith wrote:
> Can you try calling begin() on an istream_view<int>& directly, and see
> if you get the same error?
$ cat istream_begin.cpp
#include <cassert>
#include <iostream>
#include <ranges>
#include <sstream>
int main()
{
auto ints = std::istringstream{"0 1 2 3 4"};
auto view{ std::ranges::istream_view<int>(ints) };
auto begin{ std::ranges::begin(view) };
assert(&*view.begin() == &*begin);
}
$ g++ -std=c++20 istream_begin.cpp
$ ./a.out
$ clang++ -std=c++20 istream_begin.cpp
In file included from istream_begin.cpp:2:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/iostream:39:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ostream:38:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ios:40:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/char_traits.h:39:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_algobase.h:65:
In file included from
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:71:
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13:
error: no matching function for call to '__ranges_begin'
= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5:
note: in instantiation of template type alias '__range_iter_t' requested
here
using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:134:43:
note: in instantiation of template type alias 'iterator_t' requested here
data() requires contiguous_iterator<iterator_t<_Derived>>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14:
note: in instantiation of template class
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char,
std::char_traits<char> > >' requested here
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>>
^
istream_begin.cpp:9:14: note: in instantiation of template class
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >'
requested here
auto view{ std::ranges::istream_view<int>(ints) };
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885:7:
note: candidate template ignored: constraints not satisfied [with _Tp =
std::ranges::basic_istream_view<int, char, std::char_traits<char> >]
__ranges_begin(_Tp& __t)
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:16:
note: because 'is_array_v<std::ranges::basic_istream_view<int, char,
std::char_traits<char> > >' evaluated to false
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:35:
note: and 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__member_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33:
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no
member named 'begin' in 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> >'
{ __detail::__decay_copy(__t.begin()) } ->
input_or_output_iterator;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:59:
note: and 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__adl_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29:
note: because '__detail::__decay_copy(begin(__t))' would be invalid:
call to deleted function 'begin'
{ __detail::__decay_copy(begin(__t)) } ->
input_or_output_iterator;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:902:13:
error: no matching function for call to '__ranges_begin'
= decltype(__detail::__ranges_begin(std::declval<_Tp&>()));
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:874:5:
note: in instantiation of template type alias '__range_iter_t' requested
here
using iterator_t = std::__detail::__range_iter_t<_Tp>;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:140:25:
note: in instantiation of template type alias 'iterator_t' requested here
&& contiguous_iterator<iterator_t<const _Derived>>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14:
note: in instantiation of template class
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char,
std::char_traits<char> > >' requested here
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>>
^
istream_begin.cpp:9:14: note: in instantiation of template class
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >'
requested here
auto view{ std::ranges::istream_view<int>(ints) };
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:885:7:
note: candidate template ignored: constraints not satisfied [with _Tp =
const std::ranges::basic_istream_view<int, char, std::char_traits<char> >]
__ranges_begin(_Tp& __t)
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:16:
note: because 'is_array_v<const std::ranges::basic_istream_view<int,
char, std::char_traits<char> > >' evaluated to false
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:35:
note: and 'const std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__member_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33:
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no
member named 'begin' in 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> >'
{ __detail::__decay_copy(__t.begin()) } ->
input_or_output_iterator;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:883:59:
note: and 'const std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__adl_begin'
requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29:
note: because '__detail::__decay_copy(begin(__t))' would be invalid:
call to deleted function 'begin'
{ __detail::__decay_copy(begin(__t)) } ->
input_or_output_iterator;
^
In file included from istream_begin.cpp:3:
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:146:24:
error: constraints not satisfied for alias template 'sentinel_t' [with
_Range = std::ranges::basic_istream_view<int, char,
std::char_traits<char> >]
&& sized_sentinel_for<sentinel_t<_Derived>, iterator_t<_Derived>>
^~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:956:14:
note: in instantiation of template class
'std::ranges::view_interface<std::ranges::basic_istream_view<int, char,
std::char_traits<char> > >' requested here
: public view_interface<basic_istream_view<_Val, _CharT, _Traits>>
^
istream_begin.cpp:9:14: note: in instantiation of template class
'std::ranges::basic_istream_view<int, char, std::char_traits<char> >'
requested here
auto view{ std::ranges::istream_view<int>(ints) };
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:876:12:
note: because 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> >' does not satisfy 'range'
template<range _Range>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:864:2:
note: because 'ranges::begin(__t)' would be invalid: no matching
function for call to object of type 'const __cust_access::_Begin'
ranges::begin(__t);
^
In file included from istream_begin.cpp:3:
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/ranges:152:24:
error: constraints not satisfied for alias template 'sentinel_t' [with
_Range = const std::ranges::basic_istream_view<int, char,
std::char_traits<char> >]
&& sized_sentinel_for<sentinel_t<const _Derived>,
^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:876:12:
note: because 'const std::ranges::basic_istream_view<int, char,
std::char_traits<char> >' does not satisfy 'range'
template<range _Range>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:864:2:
note: because 'ranges::begin(__t)' would be invalid: no matching
function for call to object of type 'const __cust_access::_Begin'
ranges::begin(__t);
^
istream_begin.cpp:10:15: error: no matching function for call to object
of type 'const __cust_access::_Begin'
auto begin{ std::ranges::begin(view) };
^~~~~~~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:400:2:
note: candidate template ignored: constraints not satisfied [with _Tp =
std::ranges::basic_istream_view<int, char, std::char_traits<char> > &]
operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>())
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:397:11:
note: because
'is_array_v<remove_reference_t<std::ranges::basic_istream_view<int,
char, std::char_traits<char> > &> >' evaluated to false
requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:397:50:
note: and 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__member_begin'
requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:867:33:
note: because '__detail::__decay_copy(__t.begin())' would be invalid: no
member named 'begin' in 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> >'
{ __detail::__decay_copy(__t.begin()) } ->
input_or_output_iterator;
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/range_access.h:398:7:
note: and 'std::ranges::basic_istream_view<int, char,
std::char_traits<char> > &' does not satisfy '__adl_begin'
|| __adl_begin<_Tp>
^
/usr/bin/../lib64/gcc/x86_64-suse-linux/10/../../../../include/c++/10/bits/iterator_concepts.h:877:29:
note: because '__detail::__decay_copy(begin(__t))' would be invalid:
call to deleted function 'begin'
{ __detail::__decay_copy(begin(__t)) } ->
input_or_output_iterator;
^
5 errors generated.
--
Ray Lischner
More information about the cfe-users
mailing list