On Tue, 14 Oct 2025 at 16:07, Jonathan Wakely <[email protected]> wrote: > > On Tue, 14 Oct 2025 at 15:56, Jonathan Wakely <[email protected]> wrote: > > > > On Tue, 14 Oct 2025 at 22:47 +0800, Yuao Ma wrote: > > >Hi all, > > > > > >This patch adds the std::views::indices function from the C++ 26 paper > > >P3060R3. > > >Please take a look when you have time, thanks! > > > > Thanks for the patch. > > > > Attaching patches as application/octet-stream makes them hard to > > review and comment inline. If possible using 'git send-email' is the > > ideal way to submit patches. If that's not possible (it can be awkward > > to set up to send via gmail) then attaching a .txt file as text/plain > > makes things easier for reviewers. > > > > Putting the [[nodiscard]] attribute after operator() was necessary in > > previous releases of GCC due to -fconcepts-ts compatibility, but > > that's no longer relevant for GCC 16. You can just put [[nodiscard]] > > before the return type. > > > > If you're contributing under the DCO terms then please don't add the > > FSF copyright notice to new tests. And the test is not very novel or > > interesting, so the licence text isn't needed either, see > > https://gcc.gnu.org/onlinedocs/libstdc++/manual/test.html#test.new_tests > > > > > Also, I think this can be unconditionally noexcept. We know that > constructing iota_view from an integer-like type will not throw. > > For an arbitrary program-defined type that models weakly_incrementable > it could throw, but not for integer-like types.
For the testcase, I'd like to see a static_assert that the range_value_t<decltype(indices_view)> is correct, and test it with more than one type, size_t, signed short (to check there's no integral promotion involved), and an integer-like class type (std::ranges::__detail::__max_size_type). And the test should check that indices(n) is noexcept. And it would be good to check more than one size of range (so that we verify it doesn't always return only four indices! :-)
