These concepts are used to ensure valid iterators are passed to PSTL algorithms, but can also be used for other interfaces.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG6adb1ca555ec: [libc++] Add concepts that ensure a given iterator meets the syntactic…
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__iterator/check_iterators.h | ||
---|---|---|
51 ↗ | (On Diff #521822) | I am a bit uneasy about adding yet another way to check for iterator-ness, since we already have __is_cpp17_forward_iterator and the forward_iterator concept in C++20. Let's discuss this some more later when we have more time. |
libcxx/include/__iterator/check_iterators.h | ||
---|---|---|
51 ↗ | (On Diff #521822) | Ok, suggestion per our discussion:
Does that sound like a plan? I think what I mostly disliked from this as-is is that we were introducing what looked like yet another way to tell whether a type satisfied an iterator concept for C++17, but after (1) this shouldn't be an issue anymore. We could make (2) be a concept instead of constexpr bool in C++20 so that we get nicer diagnostics for users on C++20 when the static assert fails. I'd also be OK with implementing (2) as concepts directly and enabling those QOI checks only in C++20 mode. After all, those are concept checks and concept checks shouldn't really be expected before concepts exist. |
I'm going to try rolling this change out at Google to see the scope of the breakage, how many bugs it finds, and what class of bugs those are.
I'll report back in a couple of days.
libcxx/include/CMakeLists.txt | ||
---|---|---|
427 | Commit message: Add functions -- those are not functions anymore. | |
libcxx/include/__iterator/cpp17_iterator_concepts.h | ||
159 | And throughout? | |
libcxx/test/libcxx/algorithms/cpp17_iterator_concepts.verify.cpp | ||
10 | This comment needs to be updated. | |
12 | You're not testing bidirectional and random access. |
LGTM w/ comments
libcxx/include/__iterator/cpp17_iterator_concepts.h | ||
---|---|---|
49 | Per http://eel.is/c++draft/utility.arg.requirements#1.6, a = b must work if b is const. Needs a test too. | |
56–57 | I'd suggest we use _Tp instead of _Iter here, this isn't limited to iterators. | |
70 |
libcxx/include/__iterator/cpp17_iterator_concepts.h | ||
---|---|---|
70 | clang-format is doing this for some reason, and I don't really feel like adding a // clang-format off for this tiny nit. |
Commit message: Add functions -- those are not functions anymore.