Bug 100139

Summary: std::views::{take, drop} don't type erase
Product: gcc Reporter: gcc-bugs
Component: libstdc++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: ppalka, webrown.cpp
Priority: P3    
Version: 11.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2021-08-19 00:00:00

Description gcc-bugs 2021-04-18 23:38:56 UTC
Hello gcc-team,

the following code:

```cpp
#include <concepts>
#include <ranges>
#include <span>
#include <string_view>

static_assert(std::same_as<std::span<int>,
              decltype(std::views::take(std::span<int>{}, 2))>);

static_assert(std::same_as<std::string_view,
              decltype(std::views::take(std::string_view{}, 2))>);
```

does not compile (yet).

https://godbolt.org/z/6Mq7x8zaj

AFAIK this should be http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1739r0.md that was merged by https://github.com/cplusplus/draft/pull/3777.

There was a rather amusing error report at stackoverflow [1].

I tried to find that proposal in [2] but couldn't and wanted to ask if I looked at the wrong place. If you have time to implement this, that would be awesome!

Thank you!

[1] https://stackoverflow.com/questions/61867635/recursive-application-of-c20-range-adaptor-causes-a-compile-time-infinite-loop
[2] https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2020
Comment 1 Patrick Palka 2021-04-19 01:04:50 UTC
Some of the wording changes of P1739 are problematic as discussed in LWG issue 3407 (https://cplusplus.github.io/LWG/lwg-active.html#3407), which is why we don't implement it yet.  Though I suppose we could at least implement the workable parts of P1739 while waiting for the LWG issue to get resolved.
Comment 2 GCC Commits 2021-08-19 12:03:04 UTC
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55

commit r12-3021-g926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 19 11:44:57 2021 +0100

    libstdc++: Document P1739R4 status [PR100139]
    
    We should document the status of this unimplemented feature.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100139
            * doc/xml/manual/status_cxx2020.xml: Add P1739R4 to status table.
            * doc/html/manual/status.html: Regenerate.
Comment 3 GCC Commits 2021-08-19 13:59:36 UTC
The releases/gcc-11 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:31433e154f5eecb17151d77b259b13d41c0b8e7c

commit r11-8886-g31433e154f5eecb17151d77b259b13d41c0b8e7c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 19 11:44:57 2021 +0100

    libstdc++: Document P1739R4 status [PR100139]
    
    We should document the status of this unimplemented feature.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100139
            * doc/xml/manual/status_cxx2020.xml: Add P1739R4 to status table.
            * doc/html/manual/status.html: Regenerate.
    
    (cherry picked from commit 926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55)
Comment 4 GCC Commits 2021-08-19 14:08:50 UTC
The releases/gcc-10 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:321ff3ad38e05096abc4de6d3bb2150cc0f75d91

commit r10-10047-g321ff3ad38e05096abc4de6d3bb2150cc0f75d91
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 19 11:44:57 2021 +0100

    libstdc++: Document P1739R4 status [PR100139]
    
    We should document the status of this unimplemented feature.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100139
            * doc/xml/manual/status_cxx2020.xml: Add P1739R4 to status table.
            * doc/html/manual/status.html: Regenerate.
    
    (cherry picked from commit 926d4a71c7e5a2f7d17a4f943d6e7fe9f1e3ba55)