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
| #include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::iterator;
inline bool eq_nocase(char c1, char c2) { return tolower(c1) == tolower(c2); }
inline bool lt_nocase(char c1, char c2) { return tolower(c1) < tolower(c2); }
int main()
{
const char init[] = "The Standard Template Library";
vector<char> V(init, init + sizeof(init));
sort(V.begin(), V.end(), lt_nocase);
copy(V.begin(), V.end(), ostream_iterator<char>(cout));
cout << endl;
vector<char>::iterator new_end = unique(V.begin(), V.end(), eq_nocase);
copy(V.begin(), new_end, ostream_iterator<char>(cout));
cout << endl;
} |