• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>Struct template as_expr</title>
6<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8<link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9<link rel="up" href="../domain.html#id-1.3.33.5.9.4.4" title="Description">
10<link rel="prev" href="../domain.html" title="Struct template domain">
11<link rel="next" href="as_child.html" title="Struct template as_child">
12</head>
13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14<table cellpadding="2" width="100%"><tr>
15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
16<td align="center"><a href="../../../../../index.html">Home</a></td>
17<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20<td align="center"><a href="../../../../../more/index.htm">More</a></td>
21</tr></table>
22<hr>
23<div class="spirit-nav">
24<a accesskey="p" href="../domain.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../domain.html#id-1.3.33.5.9.4.4"><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="as_child.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="refentry">
27<a name="boost.proto.domain.as_expr"></a><div class="titlepage"></div>
28<div class="refnamediv">
29<h2><span class="refentrytitle">Struct template as_expr</span></h2>
30<p>boost::proto::domain::as_expr —
31            A callable unary MonomorphicFunctionObject that specifies how objects are turned into
32            Proto expressions in this domain. The resulting expression object is suitable for storage
33            in a local variable.
34          </p>
35</div>
36<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
37<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="../../../proto/reference.html#header.boost.proto.domain_hpp" title="Header &lt;boost/proto/domain.hpp&gt;">boost/proto/domain.hpp</a>&gt;
38
39</span>
40
41<span class="comment">// A callable unary MonomorphicFunctionObject that specifies how objects are
42// turned into Proto expressions in this domain. The resulting expression
43// object is suitable for storage in a local variable.</span>
44<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span>
45<span class="keyword">struct</span> <a class="link" href="as_expr.html" title="Struct template as_expr">as_expr</a> <span class="special">:</span> <span class="keyword"></span> <a class="link" href="../callable.html" title="Struct callable">proto::callable</a> <span class="special">{</span>
46  <span class="comment">// types</span>
47  <span class="keyword">typedef</span> <em class="replaceable"><code><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span></code></em> <a name="boost.proto.domain.as_expr.result_type"></a><span class="identifier">result_type</span><span class="special">;</span>
48
49  <span class="comment">// <a class="link" href="as_expr.html#id-1_3_33_5_7_2_1_1_8_6-bb">public member functions</a></span>
50  <span class="identifier">result_type</span> <a class="link" href="as_expr.html#id-1_3_33_5_7_2_1_1_8_6_1-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
51<span class="special">}</span><span class="special">;</span></pre></div>
52<div class="refsect1">
53<a name="id-1.3.33.5.9.4.4.7.4"></a><h2>Description</h2>
54<p>
55              A unary MonomorphicFunctionObject that specifies how objects are turned into Proto
56              expressions in this domain. The resulting expression object is suitable for storage
57              in a local variable. In that scenario, it is usually preferable to return
58              expressions by value; and, in the case of objects that are not yet Proto expressions,
59              to wrap them by value (if possible) in a new Proto terminal expression. (Contrast
60              this description with the description for
61              <code class="computeroutput"><a class="link" href="as_child.html" title="Struct template as_child">proto::domain::as_child</a></code>.)
62            </p>
63<p>
64              The <code class="computeroutput">as_expr</code> function object turns objects into
65              Proto expressions, if  they are not already, by making them Proto terminals held by
66              value if possible. Objects that are already Proto expressions are simply returned
67              by value. If
68              <code class="computeroutput">wants_basic_expr&lt;Generator&gt;::value</code> is true,
69              then let <span class="emphasis"><em>E</em></span> be
70              <code class="computeroutput"><a class="link" href="../basic_expr.html" title="Struct template basic_expr">proto::basic_expr</a></code>;
71              otherwise, let <span class="emphasis"><em>E</em></span> be
72              <code class="computeroutput"><a class="link" href="../expr.html" title="Struct template expr">proto::expr</a></code>.
73              Given an lvalue <code class="computeroutput">t</code> of type
74              <code class="computeroutput">T</code>:
75              </p>
76<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
77<li class="listitem">
78                  If <code class="computeroutput">T</code> is not a Proto expression type, the resulting
79                  terminal is calculated as follows:
80                  <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
81<li class="listitem">
82                      If <code class="computeroutput">T</code> is a function type, an abstract type, or
83                      a type derived from <code class="computeroutput">std::ios_base</code>, let
84                      <em class="replaceable"><code>A</code></em> be <code class="computeroutput">T &amp;</code>.
85                    </li>
86<li class="listitem">
87                      Otherwise, let <em class="replaceable"><code>A</code></em> be the type
88                      <code class="computeroutput">T</code> stripped of cv-qualifiers.
89                    </li>
90</ul></div>
91                  Then, the result of <code class="computeroutput">as_expr&lt;T&gt;()(t)</code> is
92                  <code class="computeroutput">Generator()(<em class="replaceable"><code>E</code></em>&lt;tag::terminal,
93                  term&lt; <em class="replaceable"><code>A</code></em> &gt; &gt;::make(t))</code>.
94                </li>
95<li class="listitem">
96                  Otherwise, the result is <code class="computeroutput">t</code> converted to an
97                  (un-const) rvalue.
98                </li>
99</ul></div>
100<p>
101            </p>
102<div class="refsect2">
103<a name="id-1.3.33.5.9.4.4.7.4.4"></a><h3>
104<a name="id-1_3_33_5_7_2_1_1_8_6-bb"></a><code class="computeroutput">as_expr</code> public member functions</h3>
105<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
106<pre class="literallayout"><span class="identifier">result_type</span> <a name="id-1_3_33_5_7_2_1_1_8_6_1-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span> t<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
107<div class="variablelist"><table border="0" class="variablelist compact">
108<colgroup>
109<col align="left" valign="top">
110<col>
111</colgroup>
112<tbody><tr>
113<td><p><span class="term">Parameters:</span></p></td>
114<td><div class="variablelist"><table border="0" class="variablelist compact">
115<colgroup>
116<col align="left" valign="top">
117<col>
118</colgroup>
119<tbody><tr>
120<td><p><span class="term"><code class="computeroutput">t</code></span></p></td>
121<td><p>The object to wrap.</p></td>
122</tr></tbody>
123</table></div></td>
124</tr></tbody>
125</table></div>
126</li></ol></div>
127</div>
128</div>
129</div>
130<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
131<td align="left"></td>
132<td align="right"><div class="copyright-footer">Copyright © 2008 Eric Niebler<p>
133        Distributed under the Boost Software License, Version 1.0. (See accompanying
134        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>)
135      </p>
136</div></td>
137</tr></table>
138<hr>
139<div class="spirit-nav">
140<a accesskey="p" href="../domain.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../domain.html#id-1.3.33.5.9.4.4"><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="as_child.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
141</div>
142</body>
143</html>
144