Opened 14 years ago
Closed 12 years ago
#2893 closed Library Submissions (fixed)
Function Input Iterator
| Reported by: | anonymous | Owned by: | Dave Abrahams |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | iterator |
| Version: | Severity: | Not Applicable | |
| Keywords: | iterator function input | Cc: | mikhailberis@… |
Description
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, " ") );
Attachments (3)
Change History (8)
by , 14 years ago
| Attachment: | function_input_iterator.hpp added |
|---|
by , 14 years ago
| Attachment: | function_input_iterator.html added |
|---|
Function iterator documentation (HTML)
comment:1 by , 14 years ago
| Cc: | added |
|---|
Was submitting the ticket anonymously earlier (unintentionally). Adding a comment as me (Dean Michael Berris) for proper documentation.
comment:2 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:3 by , 12 years ago
comment:4 by , 12 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Reopened until merged into release. ([67792] didn't add function_input_iterator to release.)
comment:5 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
(In [70709]) Iterator: merge several changes from trunk.
- Update iterator_facade test for #1019 (header change already merged).
- Category of each iterator is reduced to a known category before we try to find a minimum. Fixes #1517.
function_input_iteratorfrom Dean Michael Berris. Fixes #2893- Fix typo in
boost/iterator.hpp. Fixes #3434. - Always include
add_referenceheader in iterator adaptor header.
Did not merge changes for #1427.

Implementation header.