adjacent_filtered lets the first element entry through
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the adjacent_filtered adaptor and its increment() function, where the issue says the predicate is currently applied. Reproduce the provided C++ example, then trace the adaptor's first-element handling and verify that the returned range satisfies the documented postcondition without leaking 0.
Written by the indexing model from the issue text.
Description
Following on from Trac#13203…
adjacent_filtered always lets the first element of the range leak through before it starts the real filtering. This means it's easy to get it to violate its stated postcondition:
For all adjacent elements [x,y] in the returned range, bi_pred(x,y) is true.
Eg:
int main() {
const std::vector<int> a = { 0, 1, 2, 3, 4, 5 };
auto b = a | boost::adaptors::adjacent_filtered( [] (const int &x, const int &y) {
return ( ( x > 2 ) && ( y > 2 ) );
} );
for (const auto &x : b) {
std::cerr << x << "\n";
}
}
…outputs:
0
4
5
From what I can see in the code, the predicate is currently only applied in the increment() function, which leaves it too late for the first element to be checked.
- Dominant language
- C++
- Stars
- 45
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/range
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ros2/message_filters#338 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
subsurface/subsurface#4984 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-ai-edge/LiteRT-LM#3739 ·