// Demonstrating the STL list sort and unique functions. #include #include #include #include list lst(char* s) // Return list containing the characters of s // (not including the terminating null). { list x; while (*s != '\0') x.push_back(*s++); return x; } int main() { cout << "Demonstrating STL list sort and unique " << "functions." << endl; list list1 = lst("Stroustrup"); list1.sort(); assert(list1 == lst("Soprrsttuu")); list1.unique(); assert(list1 == lst("Soprstu")); }