2000-08-30 12:44:40 +00:00
|
|
|
/* The following code example is taken from the book
|
|
|
|
* "The C++ Standard Library - A Tutorial and Reference"
|
|
|
|
* by Nicolai M. Josuttis, Addison-Wesley, 1999
|
|
|
|
*
|
|
|
|
* (C) Copyright Nicolai M. Josuttis 1999.
|
|
|
|
* Permission to copy, use, modify, sell and distribute this software
|
|
|
|
* is granted provided this copyright notice appears in all copies.
|
|
|
|
* This software is provided "as is" without express or implied
|
|
|
|
* warranty, and with no claim as to its suitability for any purpose.
|
|
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
|
2001-08-23 20:33:35 +00:00
|
|
|
/* print_elements()
|
2000-08-30 12:44:40 +00:00
|
|
|
* - prints optional C-string optcstr followed by
|
|
|
|
* - all elements of the collection coll
|
|
|
|
* - separated by spaces
|
|
|
|
*/
|
|
|
|
template <class T>
|
2001-08-23 20:33:35 +00:00
|
|
|
inline void print_elements (const T& coll, const char* optcstr="")
|
2000-08-30 12:44:40 +00:00
|
|
|
{
|
|
|
|
typename T::const_iterator pos;
|
|
|
|
|
|
|
|
std::cout << optcstr;
|
|
|
|
for (pos=coll.begin(); pos!=coll.end(); ++pos) {
|
|
|
|
std::cout << *pos << ' ';
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
}
|