[Boost-bugs] [Boost C++ Libraries] #9851: Iterators from rang have different category than the range

Subject: [Boost-bugs] [Boost C++ Libraries] #9851: Iterators from rang have different category than the range
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-08 09:09:35


#9851: Iterators from rang have different category than the range
------------------------------+------------------------
 Reporter: anonymous | Owner: neilgroves
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: range
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+------------------------
 According to
 [http://www.boost.org/doc/libs/1_55_0/libs/range/doc/html/range/reference/adaptors/reference/transformed.html
 the documentation for transformed], the category is single pass, which
 means that it should be safe to include side effects in the function used:

 {{{
 int main() {
         int transformed_called = 0, filtered_called = 0;
         vector<int> a{ 1, 2, 3 };
         auto b = (a | transformed([&](int aa) {
                 ++transformed_called;
                 return aa + 1;
         }) | filtered([&](int aa) {
                 ++filtered_called;
                 return aa < 4;
         }));
         auto c = vector<int>(b::begin(b), b::end(b));
         cout << transformed_called << ", " << filtered_called << endl;
         return 0;
 }
 }}}

 However, the output of this program is "5, 3" instead of the expected "3,
 3", which means that the iterators returned by begin() and end() are
 forward iterators. I guess they should be input iterators (single pass)
 instead?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9851>
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-02-16 18:50:15 UTC