Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > ef9bad9e14fc2a68cb7c992c11d75f5e > files > 2630

libboost1-devel-1.31.0-1mdk.i586.rpm

<HTML>
<HEAD>
<TITLE>compose2.cpp</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
&nbsp;
<TABLE HEIGHT=40 WIDTH="100%">
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
<FONT face="Arial,Helvetica" size=+2><B>
&nbsp;compose2.cpp
</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">
  &copy; Copyright</A> Nicolai M. Josuttis 1999<BR>
</B></FONT>

<BR><BR><TT>
#include&nbsp;&lt;iostream&gt;<BR>
#include&nbsp;&lt;vector&gt;<BR>
#include&nbsp;&lt;algorithm&gt;<BR>
#include&nbsp;&lt;functional&gt;<BR>
#include&nbsp;"<A href="print.hpp.html">print.hpp</A>"<BR>
#include&nbsp;"<A href="compose.hpp.html">compose.hpp</A>"<BR>
using&nbsp;namespace&nbsp;std;<BR>
using&nbsp;namespace&nbsp;boost;<BR>
<BR>
int&nbsp;main()<BR>
{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;vector&lt;int&gt;&nbsp;coll;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>//&nbsp;insert&nbsp;elements&nbsp;from&nbsp;1&nbsp;to&nbsp;9</I></FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i=1;&nbsp;i&lt;=9;&nbsp;++i)&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;coll.push_back(i);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(coll);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>//&nbsp;remove&nbsp;all&nbsp;elements&nbsp;that&nbsp;are&nbsp;greater&nbsp;than&nbsp;four&nbsp;and&nbsp;less&nbsp;than&nbsp;seven</I></FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>//&nbsp;-&nbsp;retain&nbsp;new&nbsp;end</I></FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;vector&lt;int&gt;::iterator&nbsp;pos;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;pos&nbsp;=&nbsp;remove_if&nbsp;(coll.begin(),coll.end(),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compose_f_gx_hx(logical_and&lt;bool&gt;(),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bind2nd(greater&lt;int&gt;(),4),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bind2nd(less&lt;int&gt;(),7)));<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>//&nbsp;remove&nbsp;``removed''&nbsp;elements&nbsp;in&nbsp;coll</I></FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;coll.erase(pos,coll.end());<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;PRINT_ELEMENTS(coll);<BR>
}<BR>
</TT>
</BODY>
</HTML>