Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/array/print.hpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 799 bytes
Line 
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 */
17template <class T>
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}
Note: See TracBrowser for help on using the repository browser.