C++ – Print Out Objects From Set
In C++11, why use a for loop when you can use a foreach loop? In C++98/03, why use a for loop when you can use an algorithm instead? Note that this works with any pair of iterators, not only those from std::set<t>. std::copy will use your user-defined operator<< to print out every item inside the set using this single statement.