-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenera1.cpp
More file actions
48 lines (39 loc) · 747 Bytes
/
genera1.cpp
File metadata and controls
48 lines (39 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <list>
#include <algorithm>
#include <iterator>
#include <sequtils.h>
using namespace std;
class IntSeq {
private :
int value;
public :
IntSeq(int v) : value(v) {
}
int operator() () {
return value++;
}
};
int main(int argc, char *argv[])
{
list<int> col1;
IntSeq seq(1);
generate_n<back_insert_iterator<list<int> >,
int, IntSeq&>(back_inserter(col1),
4,
seq);
print_seq(col1, "col1 : ");
generate_n(back_inserter(col1),
4,
IntSeq(42));
print_seq(col1, "col1 : ");
generate_n(back_inserter(col1),
4,
seq);
print_seq(col1, "col1 : ");
generate_n(back_inserter(col1),
4,
seq);
print_seq(col1, "col1 : ");
return 0;
}