Details
- Reviewers
• Quuxplusone ldionne - Group Reviewers
Restricted Project - Commits
- rG8f1d8785df92: [libc++][ranges] Implement `permutable`.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.subsumption.compile.pass.cpp | ||
---|---|---|
19 | Please let me know if these subsumption tests aren't applicable. |
LGTM % nits!
libcxx/docs/Status/RangesPaper.csv | ||
---|---|---|
69 | Could mark this "In Progress" now. | |
libcxx/include/__iterator/permutable.h | ||
27–29 | Perhaps 2-space indent? | |
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.compile.pass.cpp | ||
38 | Instead of customizing iter_swap for forward_iterator, I'd prefer to see a hidden-friend swap for NonCopyable. That would still satisfy all your requirements for this test, right? | |
45–48 | I agree with your logic. Spelling it out here doesn't seem useful, though, because it's not the form of the argument that's difficult; it's whether all of the premises are (still) factually correct. The reader has to visit cppreference to find that out, which means they're not reading your comment after the first sentence anyway. | |
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.subsumption.compile.pass.cpp | ||
19 | Works for me. template<class I> void test_subsumption() requires std::forward_iterator<I>; template<class I> void test_subsumption() requires std::indirectly_movable_storable<I, I>; template<class I> void test_subsumption() requires std::indirectly_swappable<I, I>; template<class I> constexpr bool test_subsumption() requires std::permutable<I> { return true; } static_assert(test_subsumption<int*>()); // unambiguous but I could believe that's too "clever." Whatever you want to do here is okay, AFAIC. |
LGTM with comments.
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.compile.pass.cpp | ||
---|---|---|
45–48 | I personally dislike "cryptic" or "clever" comments that state something without explaining it at all. It assumes that the reader will immediately understand why the statement is true. This comment saves me time because I can read and understand the reasoning without having to work it out myself. | |
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.subsumption.compile.pass.cpp | ||
19 | I think this is a shorter, more copy-pastable and generally simpler way to test for subsumption than what we seem to do elsewhere. I would encourage @var-const to use something like this. I thought it out, and I *think* this is 100% equivalent to the tests we have right now. If I missed a difference, it might be worth pointing it out @Quuxplusone . | |
36 | I would add a test for subsumption of forward_iterator, like you're doing for the other ones. |
Address feedback
libcxx/include/__iterator/permutable.h | ||
---|---|---|
27–29 | The indent width for split lines doesn't seem to be specified in the LLVM style guide, but clang-format thinks it's 4: https://github.com/llvm/llvm-project/blob/07486395d2d05c9c567994456774cafdcc1611d0/clang/lib/Format/Format.cpp#L1163 | |
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.compile.pass.cpp | ||
38 | Done. Yes, I think it's better this way. | |
45–48 | I'd prefer to keep the comment (I'm open to shortening the explanation if you have any specific suggestions). I think it would make it easier for the reader to verify my logic if they don't have to make any assumptions, and should also make cross-checking with cppreference faster. | |
libcxx/test/std/iterators/iterator.requirements/alg.req.permutable/permutable.subsumption.compile.pass.cpp | ||
19 | Thanks! I like this a lot -- it's more concise and easier to copy and/or extend. |
libcxx/include/__iterator/permutable.h | ||
---|---|---|
27–29 |
Huh, I'd think the exact opposite, because the notion of what counts as "one line, split," versus "two lines," is completely fluid in C++. I don't see any logic to having 4-space indents on concept permutable = x; but only 2-space indents on concept otherable = requires (T x) { x; }; I see LLVM's default style sets the various indent widths to 2 or 4 in what I would characterize as an arbitrary fashion, and maybe it's even worth nailing them all to 2 in our .clang-format. LLVMStyle.IndentWidth = 2; LLVMStyle.ObjCBlockIndentWidth = 2; LLVMStyle.ConstructorInitializerIndentWidth = 4; LLVMStyle.ContinuationIndentWidth = 4; So, yes I feel otherwise; but not a blocker. |
libcxx/include/__iterator/permutable.h | ||
---|---|---|
27–29 | I don't think these values are arbitrary -- the regular indent width is 2 (not sure why Objective-C blocks have a separate setting, but it makes sense for the code within blocks to be indented by 2 just like regular functions and lambdas) and the indent width for continuations is 4 (and they treat constructor initializer lists as continuations).
It should be concept otherable = requires (T x) { x; }; Having requires on a separate line is a continuation; however, the contents of the requires clause should be formatted as usual, even though they are within a continuation. |
The CI failure in modular build looks unrelated (the failure is
Failed Tests (1): llvm-libc++-shared.cfg.in :: libcxx/selftest/dsl/dsl.sh.py
)
Could mark this "In Progress" now.