File: compose1.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 (54 lines) | stat: -rw-r--r-- 2,355 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
<HTML>
<HEAD>
<TITLE>compose1.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;compose1.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;&lt;iterator&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;for&nbsp;each&nbsp;element&nbsp;add&nbsp;10&nbsp;and&nbsp;multiply&nbsp;by&nbsp;5</I></FONT><BR>
&nbsp;&nbsp;&nbsp;&nbsp;transform&nbsp;(coll.begin(),coll.end(),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ostream_iterator&lt;int&gt;(cout,"&nbsp;"),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;compose_f_gx(bind2nd(multiplies&lt;int&gt;(),5),<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;bind2nd(plus&lt;int&gt;(),10)));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;cout&nbsp;&lt;&lt;&nbsp;endl;<BR>
}<BR>
</TT>
</BODY>
</HTML>