[Boost-bugs] [Boost C++ Libraries] #13202: adjacent_filtered postcondition docs differ from behaviour

Subject: [Boost-bugs] [Boost C++ Libraries] #13202: adjacent_filtered postcondition docs differ from behaviour
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-09-09 20:29:26


#13202: adjacent_filtered postcondition docs differ from behaviour
-------------------------------------------------+-------------------------
 Reporter: Tony Lewis <tonyelewis@…> | Owner: Neil Groves
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost Development Trunk | Severity:
 Keywords: | Optimization
  range,adjacent_filtered,documentation,postcondition,predicate,adaptor|
-------------------------------------------------+-------------------------
 I think the documentation for `adjacent_filtered`'s postcondition, ie:

> For all adjacent elements `[x,y]` in the returned range, `bi_pred(x,y)`
 is `true`.

 â€¦isn't quite right. For example, this:

 {{{
 #!cpp
 #include <boost/range/adaptor/adjacent_filtered.hpp>

 #include <iostream>
 #include <vector>

 int main() {
         const std::vector<int> a = { 0, 1, 2, 3, 4, 5, 6 };

         const auto b = a | boost::adaptors::adjacent_filtered(
                 [] (const int &x, const int &y) {
                         return ( y % 2 == 1 ) && ( y == x + 1 );
                 }
         );
         for (const auto &x : b) {
                 std::cerr << x << "\n";
         }
 }
 }}}

 â€¦outputs:

 {{{
 0
 1
 3
 5
 }}}

 Yet two of the pairs of adjacent elements `[x,y]` in this range fail
 `bi_pred(x,y)` (because they differ by 2, not 1).

 I think it's more like: `bi_pred` is true on each element in the returned
 range preceded by the element that preceded it in the //original// range
 (not in the //returned// range).

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13202>
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:35:41 UTC