1 /* The following code example is taken from the book 2 * "The C++ Standard Library - A Tutorial and Reference" 3 * by Nicolai M. Josuttis, Addison-Wesley, 1999 4 * 5 * (C) Copyright Nicolai M. Josuttis 1999. 6 * Distributed under the Boost Software License, Version 1.0. (See 7 * accompanying file LICENSE_1_0.txt or copy at 8 * http://www.boost.org/LICENSE_1_0.txt) 9 */ 10 #include <iostream> 11 12 /* print_elements() 13 * - prints optional C-string optcstr followed by 14 * - all elements of the collection coll 15 * - separated by spaces 16 */ 17 template <class T> print_elements(const T & coll,const char * optcstr="")18inline void print_elements (const T& coll, const char* optcstr="") 19 { 20 typename T::const_iterator pos; 21 22 std::cout << optcstr; 23 for (pos=coll.begin(); pos!=coll.end(); ++pos) { 24 std::cout << *pos << ' '; 25 } 26 std::cout << std::endl; 27 } 28