Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

adjacent_filtered lets the first element entry through

Open
#80 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/range

All issues in boostorg/range

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.