// Illustrating the generic swap_ranges algorithm #include #include #include #include #include using namespace std; template Container make(const char s[]) { return Container(&s[0], &s[strlen(s)]); } int main() { cout << "Illustrating the generic swap_ranges algorithm." << endl; vector vector1 = make< vector >("HELLO"), vector2 = make< vector >("THERE"); // Save vector1 and vector2 contents, for checking: vector temp1 = vector1, temp2 = vector2; // Swap the contents of vector1 and vector2: swap_ranges(vector1.begin(), vector1.end(), vector2.begin()); assert (vector1 == temp2 && vector2 == temp1); cout << " --- Ok." << endl; return 0; }