forked from boostorg/array
49 lines
2.0 KiB
HTML
49 lines
2.0 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>PRINT_ELEMENTS()</TITLE>
|
|
</HEAD>
|
|
|
|
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
|
|
|
|
<TABLE HEIGHT=40 WIDTH="100%">
|
|
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
|
|
<FONT face="Arial,Helvetica" size=+2><B>
|
|
PRINT_ELEMENTS()
|
|
</B></FONT>
|
|
</TD></TR></TABLE><BR>
|
|
|
|
<FONT face="Arial,Helvetica"><B>
|
|
The following code example is taken from the book<BR>
|
|
<A HREF="http://www.josuttis.com/libbook/" TARGET="_top">
|
|
The C++ Standard Library - A Tutorial and Reference</A><BR>
|
|
by Nicolai M. Josuttis, Addison-Wesley, 1999<BR>
|
|
<A HREF="http://www.josuttis.com/libbook/copyright.html">
|
|
© Copyright</A> Nicolai M. Josuttis 1999<BR>
|
|
</B></FONT>
|
|
|
|
<BR><BR>
|
|
<TT>
|
|
<SPAN class="Source">
|
|
#include <iostream><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* print_elements()</FONT></I><BR>
|
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* - prints optional C-string optcstr followed by</FONT></I><BR>
|
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* - all elements of the collection coll</FONT></I><BR>
|
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >* - separated by spaces</FONT></I><BR>
|
|
<I><FONT face="Arial,Helvetica,sans-serif" color="0000FF" >*/</FONT></I><BR>
|
|
template <class T><BR>
|
|
inline void print_elements (const T& coll, const char* optcstr="")<BR>
|
|
{<BR>
|
|
typename T::const_iterator pos;<BR>
|
|
<BR>
|
|
std::cout << optcstr;<BR>
|
|
for (pos=coll.begin(); pos!=coll.end(); ++pos) {<BR>
|
|
std::cout << *pos << ' ';<BR>
|
|
}<BR>
|
|
std::cout << std::endl;<BR>
|
|
}<BR>
|
|
</SPAN>
|
|
</TT>
|
|
</BODY>
|
|
</HTML>
|