]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Values</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 1. Phoenix 3.2.0"> | |
8 | <link rel="up" href="../core.html" title="Core"> | |
9 | <link rel="prev" href="../core.html" title="Core"> | |
10 | <link rel="next" href="references.html" title="References"> | |
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="../core.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.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="references.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h4 class="title"> | |
27 | <a name="phoenix.modules.core.values"></a><a class="link" href="values.html" title="Values">Values</a> | |
28 | </h4></div></div></div> | |
29 | <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> | |
30 | </pre> | |
31 | <p> | |
32 | Whenever we see a constant in a partially applied function, an | |
33 | </p> | |
34 | <pre class="programlisting"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> | |
35 | </pre> | |
36 | <p> | |
37 | (where T is the type of the constant) is automatically created for us. | |
38 | For instance: | |
39 | </p> | |
40 | <pre class="programlisting"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span> | |
41 | </pre> | |
42 | <p> | |
43 | Passing a second argument, <code class="computeroutput"><span class="number">6</span></code>, | |
44 | an <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span></code> is implicitly created behind the | |
45 | scenes. This is also equivalent to <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">val</span><span class="special">(</span><span class="number">6</span><span class="special">))</span></code>. | |
46 | </p> | |
47 | <pre class="programlisting"><span class="identifier">val</span><span class="special">(</span><span class="identifier">v</span><span class="special">)</span> | |
48 | </pre> | |
49 | <p> | |
50 | generates an <code class="computeroutput"><span class="identifier">expression</span><span class="special">::</span><span class="identifier">value</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span></code> | |
51 | where <code class="computeroutput"><span class="identifier">T</span></code> is the type of | |
52 | <code class="computeroutput"><span class="identifier">x</span></code>. In most cases, there's | |
53 | no need to explicitly use <code class="computeroutput"><span class="identifier">val</span></code>, | |
54 | but, as we'll see later on, there are situations where this is unavoidable. | |
55 | </p> | |
56 | <h3> | |
57 | <a name="phoenix.modules.core.values.h0"></a> | |
58 | <span><a name="phoenix.modules.core.values.evaluating_a_value"></a></span><a class="link" href="values.html#phoenix.modules.core.values.evaluating_a_value">Evaluating | |
59 | a Value</a> | |
60 | </h3> | |
61 | <p> | |
62 | Like arguments, values are also actors. As such, values can be evaluated. | |
63 | Invoking a value gives the value's identity. Example: | |
64 | </p> | |
65 | <pre class="programlisting"><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">val</span><span class="special">(</span><span class="number">3</span><span class="special">)()</span> <span class="special"><<</span> <span class="identifier">val</span><span class="special">(</span><span class="string">"Hello World"</span><span class="special">)();</span> | |
66 | </pre> | |
67 | <p> | |
68 | prints out "3 Hello World". | |
69 | </p> | |
70 | </div> | |
71 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
72 | <td align="left"></td> | |
73 | <td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas | |
74 | Heller, John Fletcher<p> | |
75 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
76 | 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>) | |
77 | </p> | |
78 | </div></td> | |
79 | </tr></table> | |
80 | <hr> | |
81 | <div class="spirit-nav"> | |
82 | <a accesskey="p" href="../core.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.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="references.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> | |
83 | </div> | |
84 | </body> | |
85 | </html> |