Debian Codegraph @

yo/concrete/examples/stringptrs/iterators.cc

raw
1 #include <iostream>
2 #include <algorithm>
3
4 #include "stringptr.h"
5
6 using namespace std;
7
8 int main(int argc, char **argv)
9 {
10 StringPtr sp;
11
12 while (*argv)
13 sp.push_back(new string{ *argv++ });
14
15
16 sort(sp.begin(), sp.end());
17 copy(sp.begin(), sp.end(), ostream_iterator<string>(cout, " "));
18
19 cout << "\n======\n";
20
21 sort(sp.rbegin(), sp.rend());
22 copy(sp.begin(), sp.end(), ostream_iterator<string>(cout, " "));
23
24 cout << '\n';
25 }
26
27 /*
28 when called as:
29 a.out bravo mike charlie zulu quebec
30
31 generated output:
32 a.out bravo charlie mike quebec zulu
33 ======
34 zulu quebec mike charlie bravo a.out
35 */