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