Details
- Reviewers
ldionne Mordante var-const - Group Reviewers
Restricted Project - Commits
- rGb79b2b677256: [libc++] Implement ranges::find_first_of
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
In general looks good modulo some minor issues. But before approving I like to know whether or not we want to avoid code duplication between the "old" algorithms and their ranges based equivalents.
libcxx/include/__algorithm/ranges_find_first_of.h | ||
---|---|---|
43 | I saw @ldionne recently raised some concerns regarding duplicating algorithms for the ranges and non-ranges version. Have we found a solution for that concern? | |
libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/ranges.find_first_of.pass.cpp | ||
76 | I find it a bit confusion the have an array<int, x> and an int expected not related. | |
102 | This is a duplicate of line 99. | |
113 | I would like to see two non-empty ranges that have no match at all. For example | |
148 | For clarity I would prefer to use std::begin() and std::end() here. | |
208 |
- Address comments
libcxx/include/__algorithm/ranges_find_first_of.h | ||
---|---|---|
43 | I think we have to decide that on a case-by-case basis. There are cases where I think it's more hassle than it's worth like here and there are cases where it's a definite win, like copy or move. There are of course also cases where it's not really clear, like binary_search. Note that there are optimizations possible for the ranges algorithms which are simply not possible for the classical algorithms (like in ranges::is_permutation) and ones where making optimizations for the ranges version properly is a lot harder (like ranges::move). |
LGTM, modulo one comment.
Since I'm not too involved in ranges I prefer to leave the final approval to @var-const or @ldionne.
libcxx/include/__algorithm/ranges_find_first_of.h | ||
---|---|---|
43 | Thanks for the info! | |
libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/ranges.find_first_of.pass.cpp | ||
148 | Can you do the same for similar places in the tests? |
Almost LGTM, just some nits.
libcxx/docs/Status/RangesAlgorithms.csv | ||
---|---|---|
7–8 | Nit: please update the link. Also, I don't think there should be a space between the tilde and the < character. | |
libcxx/include/__algorithm/ranges_find_first_of.h | ||
44 | Why are we creating a new variable instead of incrementing __first2, which would be consistent with __first1? | |
libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/ranges.find_first_of.pass.cpp | ||
98 | (By the way, I like these "named arguments") | |
107 | For exhaustiveness, I'd also add a test case when input2 consists of a single element (currently, all the successful cases have input2 with several elements). | |
123 | Nit: unnecessary blank line. | |
171 | Great test, can you please check if there are any other range algorithm tests where a similar test would be valuable? | |
183 | Nit: swap the order, so that the iterator overload goes before the range overload? | |
222 | Question: perhaps check for the exact value? |
libcxx/include/__algorithm/ranges_find_first_of.h | ||
---|---|---|
44 | Because we go a few times over [__first2, __last2). | |
libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/ranges.find_first_of.pass.cpp | ||
171 | I think I mostly added this test to other ranges algorithms. A few of the first ones might be missing a few tests, but I think that is a problem for later. They should probably be refactored and extended at some point. |
libcxx/include/__algorithm/ranges_find_first_of.h | ||
---|---|---|
44 | Oh, sorry for missing that, it's quite obvious. |
Nit: please update the link. Also, I don't think there should be a space between the tilde and the < character.