]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/phoenix/doc/html/phoenix/modules/statement.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / phoenix / doc / html / phoenix / modules / statement.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4<title>Statement</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
8<link rel="up" href="../modules.html" title="Modules">
9<link rel="prev" href="operator.html" title="Operator">
10<link rel="next" href="statement/block_statement.html" title="Block Statement">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="operator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="statement/block_statement.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="phoenix.modules.statement"></a><a class="link" href="statement.html" title="Statement">Statement</a>
28</h3></div></div></div>
29<div class="toc"><dl>
30<dt><span class="section"><a href="statement/block_statement.html">Block Statement</a></span></dt>
31<dt><span class="section"><a href="statement/if__statement.html">if_ Statement</a></span></dt>
32<dt><span class="section"><a href="statement/___if_else_____statement.html">if_else_ Statement</a></span></dt>
33<dt><span class="section"><a href="statement/switch__statement.html">switch_
34 Statement</a></span></dt>
35<dt><span class="section"><a href="statement/while__statement.html">while_
36 Statement</a></span></dt>
37<dt><span class="section"><a href="statement/___do_while_____statement.html">do_while_ Statement</a></span></dt>
38<dt><span class="section"><a href="statement/for_statement.html">for_ Statement</a></span></dt>
39<dt><span class="section"><a href="statement/try__catch__statement.html">try_
40 catch_ Statement</a></span></dt>
41<dt><span class="section"><a href="statement/throw_.html">throw_</a></span></dt>
42</dl></div>
43<p>
44 <span class="bold"><strong><span class="emphasis"><em>Lazy statements...</em></span></strong></span>
45 </p>
46<p>
47 The expressions presented so far are sufficiently powerful to construct quite
48 elaborate structures. We have presented lazy-functions and lazy-operators.
49 How about lazy-statements? First, an appetizer:
50 </p>
51<p>
52 Print all odd-numbered contents of an STL container using <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
53 (<a href="../../../../example/all_odds.cpp" target="_top">all_odds.cpp</a>):
54 </p>
55<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">c</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">c</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span>
56 <span class="identifier">if_</span><span class="special">(</span><span class="identifier">arg1</span> <span class="special">%</span> <span class="number">2</span> <span class="special">==</span> <span class="number">1</span><span class="special">)</span>
57 <span class="special">[</span>
58 <span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg1</span> <span class="special">&lt;&lt;</span> <span class="char">' '</span>
59 <span class="special">]</span>
60<span class="special">);</span>
61</pre>
62<p>
63 Huh? Is that valid C++? Read on...
64 </p>
65<p>
66 Yes, it is valid C++. The sample code above is as close as you can get to
67 the syntax of C++. This stylized C++ syntax differs from actual C++ code.
68 First, the <code class="computeroutput"><span class="keyword">if</span></code> has a trailing
69 underscore. Second, the block uses square brackets instead of the familiar
70 curly braces {}.
71 </p>
72<div class="note"><table border="0" summary="Note">
73<tr>
74<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
75<th align="left">Note</th>
76</tr>
77<tr><td align="left" valign="top">
78<p>
79 <span class="bold"><strong>C++ in C++?</strong></span>
80 </p>
81<p>
82 In as much as <a href="http://spirit.sourceforge.net" target="_top">Spirit</a>
83 attempts to mimic EBNF in C++, Phoenix attempts to mimic C++ in C++!!!
84 </p>
85</td></tr>
86</table></div>
87<div class="note"><table border="0" summary="Note">
88<tr>
89<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
90<th align="left">Note</th>
91</tr>
92<tr><td align="left" valign="top"><p>
93 Unlike lazy functions and lazy operators, lazy statements always return
94 void.
95 </p></td></tr>
96</table></div>
97<p>
98 Here are more examples with annotations. The code almost speaks for itself.
99 </p>
100</div>
101<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
102<td align="left"></td>
103<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
104 Heller, John Fletcher<p>
105 Distributed under the Boost Software License, Version 1.0. (See accompanying
106 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
107 </p>
108</div></td>
109</tr></table>
110<hr>
111<div class="spirit-nav">
112<a accesskey="p" href="operator.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../modules.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="statement/block_statement.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
113</div>
114</body>
115</html>