Imported Upstream version 1.57.0
[platform/upstream/boost.git] / doc / html / boost / xpressive / local.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Struct template local</title>
5 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="../../xpressive/reference.html#header.boost.xpressive.regex_actions_hpp" title="Header &lt;boost/xpressive/regex_actions.hpp&gt;">
9 <link rel="prev" href="reference.html" title="Struct template reference">
10 <link rel="next" href="placeholder.html" title="Struct template placeholder">
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="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../xpressive/reference.html#header.boost.xpressive.regex_actions_hpp"><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="placeholder.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="refentry">
26 <a name="boost.xpressive.local"></a><div class="titlepage"></div>
27 <div class="refnamediv">
28 <h2><span class="refentrytitle">Struct template local</span></h2>
29 <p>boost::xpressive::local &#8212; <code class="computeroutput">local&lt;&gt;</code> is a lazy wrapper for a reference to a value that is stored within the local itself. It is for use within xpressive semantic actions. </p>
30 </div>
31 <h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32 <div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../xpressive/reference.html#header.boost.xpressive.regex_actions_hpp" title="Header &lt;boost/xpressive/regex_actions.hpp&gt;">boost/xpressive/regex_actions.hpp</a>&gt;
33
34 </span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
35 <span class="keyword">struct</span> <a class="link" href="local.html" title="Struct template local">local</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">terminal</span><span class="special">::</span><span class="identifier">type</span><span class="special">&lt;</span> <span class="identifier">reference_wrapper</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">{</span>
36   <span class="comment">// <a class="link" href="local.html#boost.xpressive.localconstruct-copy-destruct">construct/copy/destruct</a></span>
37   <a class="link" href="local.html#idp355264672-bb"><span class="identifier">local</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
38   <span class="keyword">explicit</span> <a class="link" href="local.html#idp355265728-bb"><span class="identifier">local</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
39
40   <span class="comment">// <a class="link" href="local.html#idp355261136-bb">public member functions</a></span>
41   <span class="identifier">T</span> <span class="special">&amp;</span> <a class="link" href="local.html#idp355261696-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
42   <span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> <a class="link" href="local.html#idp355262848-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
43 <span class="special">}</span><span class="special">;</span></pre></div>
44 <div class="refsect1">
45 <a name="idp533982976"></a><h2>Description</h2>
46 <p>
47 Below is an example of how to use <code class="computeroutput">local&lt;&gt;</code> in semantic actions.</p>
48 <pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">xpressive</span><span class="special">;</span>
49 <a class="link" href="local.html" title="Struct template local">local&lt;int&gt;</a> <span class="identifier">i</span><span class="special">(</span><span class="number">0</span><span class="special">)</span><span class="special">;</span>
50 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">str</span><span class="special">(</span><span class="string">"1!2!3?"</span><span class="special">)</span><span class="special">;</span>
51 <span class="comment">// count the exciting digits, but not the</span>
52 <span class="comment">// questionable ones.</span>
53 <a class="link" href="basic_regex.html" title="Struct template basic_regex">sregex</a> <span class="identifier">rex</span> <span class="special">=</span> <span class="special">+</span><span class="special">(</span> <span class="identifier">_d</span> <span class="special">[</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">]</span> <span class="special">&gt;&gt;</span> <span class="char">'!'</span> <span class="special">)</span><span class="special">;</span>
54 <span class="identifier">regex_search</span><span class="special">(</span><span class="identifier">str</span><span class="special">,</span> <span class="identifier">rex</span><span class="special">)</span><span class="special">;</span>
55 <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">i</span><span class="special">.</span><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="special">==</span> <span class="number">2</span> <span class="special">)</span><span class="special">;</span>
56 </pre>
57 <p> </p>
58 <div class="note"><table border="0" summary="Note">
59 <tr>
60 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../doc/src/images/note.png"></td>
61 <th align="left">Note</th>
62 </tr>
63 <tr><td align="left" valign="top"><p>As the name "local" suggests, <code class="computeroutput">local&lt;&gt;</code> objects and the regexes that refer to them should never leave the local scope. The value stored within the local object will be destroyed at the end of the <code class="computeroutput">local&lt;&gt;'s</code> lifetime, and any regex objects still holding the <code class="computeroutput">local&lt;&gt;</code> will be left with a dangling reference. </p></td></tr>
64 </table></div>
65 <p>
66 </p>
67 <div class="refsect2">
68 <a name="idp534020544"></a><h3>Template Parameters</h3>
69 <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
70 <pre class="literallayout"><span class="keyword">typename</span> T</pre>
71 <p>The type of the local variable.</p>
72 </li></ol></div>
73 </div>
74 <div class="refsect2">
75 <a name="idp534023680"></a><h3>
76 <a name="boost.xpressive.localconstruct-copy-destruct"></a><code class="computeroutput">local</code> 
77         public
78        construct/copy/destruct</h3>
79 <div class="orderedlist"><ol class="orderedlist" type="1">
80 <li class="listitem">
81 <pre class="literallayout"><a name="idp355264672-bb"></a><span class="identifier">local</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Store a default-constructed value of type <code class="computeroutput">T</code>. </li>
82 <li class="listitem">
83 <pre class="literallayout"><span class="keyword">explicit</span> <a name="idp355265728-bb"></a><span class="identifier">local</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> t<span class="special">)</span><span class="special">;</span></pre>Store a default-constructed value of type <code class="computeroutput">T</code>. <p>
84 </p>
85 <div class="variablelist"><table border="0" class="variablelist compact">
86 <colgroup>
87 <col align="left" valign="top">
88 <col>
89 </colgroup>
90 <tbody><tr>
91 <td><p><span class="term">Parameters:</span></p></td>
92 <td><div class="variablelist"><table border="0" class="variablelist compact">
93 <colgroup>
94 <col align="left" valign="top">
95 <col>
96 </colgroup>
97 <tbody><tr>
98 <td><p><span class="term"><code class="computeroutput">t</code></span></p></td>
99 <td><p>The initial value. </p></td>
100 </tr></tbody>
101 </table></div></td>
102 </tr></tbody>
103 </table></div>
104 </li>
105 </ol></div>
106 </div>
107 <div class="refsect2">
108 <a name="idp534040768"></a><h3>
109 <a name="idp355261136-bb"></a><code class="computeroutput">local</code> public member functions</h3>
110 <div class="orderedlist"><ol class="orderedlist" type="1">
111 <li class="listitem">
112 <pre class="literallayout"><span class="identifier">T</span> <span class="special">&amp;</span> <a name="idp355261696-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Fetch the wrapped value. </li>
113 <li class="listitem">
114 <pre class="literallayout"><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span> <a name="idp355262848-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
115 <p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>
116 </li>
117 </ol></div>
118 </div>
119 </div>
120 </div>
121 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
122 <td align="left"></td>
123 <td align="right"><div class="copyright-footer">Copyright &#169; 2007 Eric Niebler<p>
124         Distributed under the Boost Software License, Version 1.0. (See accompanying
125         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>)
126       </p>
127 </div></td>
128 </tr></table>
129 <hr>
130 <div class="spirit-nav">
131 <a accesskey="p" href="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../xpressive/reference.html#header.boost.xpressive.regex_actions_hpp"><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="placeholder.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
132 </div>
133 </body>
134 </html>