[Boost-bugs] [Boost C++ Libraries] #13203: adjacent_filtered lets the first element entry through

Subject: [Boost-bugs] [Boost C++ Libraries] #13203: adjacent_filtered lets the first element entry through
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-09 20:40:01


#13203: adjacent_filtered lets the first element entry through
-------------------------------------------------+-------------------------
 Reporter: Tony Lewis <tonyelewis@…> | Owner: Neil Groves
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
  adjacent_filtered,adaptor,range,predicate,leak |
-------------------------------------------------+-------------------------
 `adjacent_filtered` always lets the first element of the range leak
 through, even for a predicate that rejects that element as either
 argument. Eg.

 {{{
 #!cpp
 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.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13203>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-09-09 20:46:10 UTC