Debian Codegraph @

yo/classtemplates/examples/stringptrs/iterators.cc

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