[Boost-bugs] [Boost C++ Libraries] #2893: Function Input Iterator

Subject: [Boost-bugs] [Boost C++ Libraries] #2893: Function Input Iterator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-03-27 11:13:28


#2893: Function Input Iterator
-------------------------------------+--------------------------------------
 Reporter: anonymous | Owner: dave
     Type: Library Submissions | Status: new
Milestone: To Be Determined | Component: iterator
  Version: | Severity: Not Applicable
 Keywords: iterator function input |
-------------------------------------+--------------------------------------
 Simply put a the function input iterator implementation wraps a nullary
 function object and allows for bounded iterators using an embedded state
 variable. The use case is for something like the following:

 {{{
 struct generator {
  typedef int result_type;
  generator() { srand(time(0)); }
  result_type operator() () const { return rand(); }
 };

 using namespace std;
 using namespace boost;

 int main(int argc, char * argv[]) {
  generator f;
  copy(
    make_function_input_iterator(f, infinite()),
    make_function_input_iterator(f, infinite()),
    ostream_iterator<int>(cout, " ")
    );
  return 0;
 }
 }}}

 And if you don't want an infinite range, you can simply bound it:

 {{{
 copy(
   make_function_input_iterator(f, 0),
   make_function_input_iterator(f, 10),
   ostream_iterator<int>(cout, " ")
 );
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2893>
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:49:59 UTC