mirror of
https://github.com/boostorg/compose.git
synced 2026-01-23 05:22:15 +00:00
46 lines
1.9 KiB
HTML
46 lines
1.9 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>
|
|
#include <iostream><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* PRINT_ELEMENTS()</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* - prints optional C-string optcstr followed by</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* - all elements of the collection coll</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* - separated by spaces</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><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>
|
|
</TT>
|
|
</BODY>
|
|
</HTML>
|