<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/75611>75611</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [libc++] `views::take` behaves incorrectly for `iota_view`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          frederick-vs-ja
      </td>
    </tr>
</table>

<pre>
    Discovered in analysis for microsoft/STL#4263.

https://github.com/llvm/llvm-project/blob/214d32ccd2be05262a328563d3792ec0d36404b0/libcxx/include/__ranges/take_view.h#L290-L303

Currently, when libc++'s `views::take` specially handles an `iota_view`, the addition is done after deference the beginning iterator.
However, in [[range.take.overview]/2.3](https://eel.is/c++draft/range.take.overview#2.3), the deferencing is done after addition, which means that the standard requires the returned `iota_view` to have the same `W` and `Bound` type in such cases.

https://github.com/llvm/llvm-project/blob/214d32ccd2be05262a328563d3792ec0d36404b0/libcxx/test/std/ranges/range.adaptors/range.take/adaptor.pass.cpp#L177

Also, the test file is testing the incorrect behavior.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElMFu4zYQhp-GuhARqKEkWwcdkjWEHnJrgR4DihxZ3KVJlUM567cvyMTdZNEeelrAsC1x-HP-b4ajiOzZI46se2LdqVJ7WkMcl4gGo9XfHq708FVVczC38WRJhytGNNx6rrxyN7LElxD5xeoYKCyJwfT7H88MZAu9rJk4MfH49r2mtBGTjwwmBtPZpnWfax0uDCbnrvefhy2Gr6izzuzCzGCCpjUStDYwo-igByXh2PXSyMMAqIWRfSvaWWQBO-vv3xlM1mu3G2QwvbxE5c9IDKakvuHL1eJrvTKQzzCIh2cp5Mccv-wxok_uxuALf13R8yzJ4Kl8DsRZL7JC8SEfsyLrBacNtVXO3fiqvHFIXPkcakNS5UTWi6yYVuTKGJts8NwSN8EjV0vCyA0uGNFrLEEznq331p-5TRhVCvEd5W_hFa8Ys5j1vNTsqRiscy51rk45rztlcrUsf46f0SO62mYg78ZMVKVu_6YDMovAcM_-nmZJ7ZOBu683clav_ILKE0-rSmUrJeWNioZH_Gu3Eam8jZj26NH8jIunwFd1fcNB6oI54M-8oHwJfgq7NyXwtmGGQbteuVaE9MvaLiFlBUrmjpP-4aqM2lKI9Ak0g-n9fb0polpvW27N5nD4aOHRUbgXIB_BF-sw488PuRJ5wXodYkSd-IyrutoQ68qM0gxyUBWOzUFA3w6NENU6YqPl0gyLOAydwmHo9aEzreiPvdHzMhwrO4IA2UDTNa1oO1nDsRHYN9AK0QKYjrUCL8q6OsOrQzxXlmjH8dD1TVM5NaOjMlIAPt4gyCMmjoX4vJ-JtcJZSvRDJtnkyjD6sK07_ce9K06Rfnh3tzKNfuqlao9u_N99UAzlchVPfwcAAP__U6Giow">