File: compose2.cpp.html

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (59 lines) | stat: -rw-r--r-- 2,996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<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>