[PATCH] libstdc++: Define C++20 range utilities and range factories

Jonathan Wakely jwakely@redhat.com
Tue Nov 19 08:51:00 GMT 2019


On 19/11/19 09:38 +0100, Stephan Bergmann wrote:
>On 17/11/2019 02:07, Jonathan Wakely wrote:
>>This adds another chunk of the <ranges> header.
>>
>>The changes from P1456R1 (Move-only views) and P1862R1 (Range adaptors
>>for non-copyable iterators) are included, but not the changes from
>>P1870R1 (forwarding-range<T> is too subtle).
>>
>>The tests for subrange and iota_view are poor and should be improved.
>
>At least with recent Clang trunk, with -std=c++2a this causes failures like
>
>>In file included from gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/set:61:
>>gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/bits/stl_set.h:1057:48: error: default initialization of an object of const type 'const bool'
>>  template<typename _Tp> inline constexpr bool __enable_view_impl;
>>                                               ^
>>In file included from gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/set:62:
>>gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/bits/stl_multiset.h:1045:48: error: redefinition of '__enable_view_impl'
>>  template<typename _Tp> inline constexpr bool __enable_view_impl;
>>                                               ^
>>gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/bits/stl_set.h:1057:48: note: previous definition is here
>>  template<typename _Tp> inline constexpr bool __enable_view_impl;
>>                                               ^
>
>and I'm not sure whether this is legal C++20 code that Clang is just 
>not capable of handling?

I'm not sure either. I checked with GCC and it did what I expected
(the first declaration is not a definition, just a declaration). I'll
check if that's valid.

For now the simplest fix would be to just guard all those variable
templates with #if __cpp_lib_concepts since std::ranges::enable_view
only exists when concepts are supported (which is false for Clang).

I'll look into it, thanks for the heads up.




More information about the Libstdc++ mailing list