Details
- Reviewers
ldionne zoecarver Mordante • Quuxplusone - Group Reviewers
Restricted Project
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__iterator/distance.h | ||
---|---|---|
40–45 | Please put lines 40-45 in an else block, so that we don't instantiate them unnecessarily in the case that the if block is taken. | |
48–55 | I notice we're not doing the noexcept thing here. Is that because https://eel.is/c++draft/range.iter.op.distance#3 says merely "equivalent to" instead of the term of power "expression-equivalent to"? | |
libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/distance.verify.cpp | ||
17 | I don't think you're (that is, I don't think the programmer is) allowed to add your own types to namespace std::ranges. | |
39–46 | We could do this in a .pass.cpp by SFINAE-testing the well-formedness of distance(r), instead of relying on the exact wording of the compiler error and then having to skip the test for non-Clang compilers. |
libcxx/include/__iterator/distance.h | ||
---|---|---|
48–55 | Yes. As it is, the noexcept specifiers would either be really difficult to read or would need their own special functions, neither of which I'm keen to do. I've just noticed that having four overloads won't hurt readability like it did with ranges::advance, so I think I can get away with making ranges::distance noexcept without it being a colossal eyesore. (I might have fixed the problem with ranges::advance, so I'll need to go back and check soon.) | |
libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/distance.verify.cpp | ||
17 | I'm aware users aren't allowed to do this, but we're testing the standard library here. We need to ensure that ADL doesn't find something in the same namespace as the function, but there's nothing to test with (no range adaptors have been merged with main yet). | |
39–46 | Something like this? template<class T> constexpr bool is_adl_friendly = requires(T t) { distance(t); }; static_assert(!is_adl_friendly<std::ranges::forward_iterator>); static_assert(!is_adl_friendly<std::ranges::some_range>); |
SGTM. no real comments from me, I'll have another look after you addressed Arthur's review comments.
libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/distance.verify.cpp | ||
---|---|---|
17 | Would it make sense to add a TODO and improve this test after we have adaptors? |
libcxx/include/__iterator/distance.h | ||
---|---|---|
35 | Drop [[nodiscard]] | |
libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/distance.pass.cpp | ||
13 | Please split into two test files, one for each overload. | |
45 | Can we avoid using a global range here (and below) and instead have a local variable? It's a tiny difference but it helps local reasoning. | |
libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/distance.verify.cpp | ||
17 | @cjdb Please add a TODO like you've done in other patches, we'll go back and fix it as soon as we check-in an adaptor. | |
libcxx/test/support/test_iterators.h | ||
877 | Drop [[nodiscard]] from the tests (here and elsewhere), except for really vexing cases as we've discussed (but I don't think there's any). |
Changes to be applied in the next day or so.
libcxx/include/__iterator/distance.h | ||
---|---|---|
35 | After much deliberation on this, I think it's worth considering that we keep [[nodiscard]] on anything that consumes a proper input_iterator or output_iterator. Two reasons:
|
Drop [[nodiscard]]