[PATCH 3/3] libstdc++: Implement C++20 range adaptors
Jonathan Wakely
jwakely@redhat.com
Tue Feb 18 23:41:00 GMT 2020
On 18/02/20 21:11 +0100, Stephan Bergmann wrote:
>On 18/02/2020 12:56, Jonathan Wakely wrote:
>>Does this solve the problem, and work with both compilers?
>>
>>diff --git a/libstdc++-v3/include/std/ranges
>>b/libstdc++-v3/include/std/ranges
>>index b9ac528fdff..481ba75ee5e 100644
>>--- a/libstdc++-v3/include/std/ranges
>>+++ b/libstdc++-v3/include/std/ranges
>>@@ -1102,6 +1102,9 @@ namespace views
>> }
>> };
>>
>>+ template<typename _Callable>
>>+ _RangeAdaptor(_Callable) -> _RangeAdaptor<_Callable>;
>>+
>> template<typename _Callable>
>> struct _RangeAdaptorClosure : public _RangeAdaptor<_Callable>
>> {
>>
>>
>>With this deduction guide CTAD should work, without having to consider
>>the constraints on the constructors.
>
>Yes, that indeed compiles with both GCC and Clang.
Fixed with this patch, which also introduces some new typedefs to
avoid having to evaluate the iterator_t alias template again and
again.
Tested powerpc64le-linux, committed to master.
There's still something not quite right, because this compiles fine
with GCC but not with Clang:
#include <ranges>
int main()
{
int a[1] = { 2 };
auto f = a | std::views::filter([](auto&&){return true;});
return *std::ranges::begin(f);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 9881 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20200218/c0023d75/attachment.bin>
More information about the Gcc-patches
mailing list