Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/refmanual/lambda.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 10.4 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost -->
5<!-- Software License, Version 1.0. (See accompanying -->
6<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
7<head>
8<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
10<title>The MPL Reference Manual: lambda</title>
11<link rel="stylesheet" href="../style.css" type="text/css" />
12</head>
13<body class="docframe refmanual">
14<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./placeholders.html" class="navigation-link">Prev</a>&nbsp;<a href="./bind.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./placeholders.html" class="navigation-link">Back</a>&nbsp;<a href="./bind.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
15<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./composition-and-argument.html" class="navigation-link">Composition and Argument Binding</a> / <a href="./lambda.html" class="navigation-link">lambda</a></td>
16</tr></table><div class="header-separator"></div>
17<div class="section" id="lambda">
18<h1><a class="toc-backref" href="./composition-and-argument.html#id456" name="lambda">lambda</a></h1>
19<div class="section" id="lambda-synopsis">
20<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
21<pre class="literal-block">
22template&lt; 
23      typename X
24    , typename Tag = <em>unspecified</em>
25    &gt;
26struct <a href="./lambda.html" class="identifier">lambda</a>
27{
28    typedef <em>unspecified</em> type;
29};
30</pre>
31</div>
32<div class="section" id="composition-lambda-description">
33<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
34<p>If <tt class="literal"><span class="pre">X</span></tt> is a <a class="reference" href="./placeholder-expression.html">Placeholder Expression</a>, transforms <tt class="literal"><span class="pre">X</span></tt> into a corresponding
35<a class="reference" href="./metafunction-class.html">Metafunction Class</a>, otherwise <tt class="literal"><span class="pre">X</span></tt> is returned unchanged.</p>
36</div>
37<div class="section" id="lambda-header">
38<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
39<pre class="literal-block">
40#include &lt;<a href="../../../../boost/mpl/lambda.hpp" class="header">boost/mpl/lambda.hpp</a>&gt;
41</pre>
42</div>
43<div class="section" id="lambda-parameters">
44<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
45<table border="1" class="table">
46<colgroup>
47<col width="18%" />
48<col width="27%" />
49<col width="55%" />
50</colgroup>
51<thead valign="bottom">
52<tr><th>Parameter</th>
53<th>Requirement</th>
54<th>Description</th>
55</tr>
56</thead>
57<tbody valign="top">
58<tr><td><tt class="literal"><span class="pre">X</span></tt></td>
59<td>Any type</td>
60<td>An expression to transform.</td>
61</tr>
62<tr><td><tt class="literal"><span class="pre">Tag</span></tt></td>
63<td>Any type</td>
64<td>A tag determining transform semantics.</td>
65</tr>
66</tbody>
67</table>
68</div>
69<div class="section" id="lambda-expression-semantics">
70<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
71<p>For arbitrary types <tt class="literal"><span class="pre">x</span></tt> and <tt class="literal"><span class="pre">tag</span></tt>:</p>
72<pre class="literal-block">
73typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;x&gt;::type f;
74</pre>
75<table class="field-list" frame="void" rules="none">
76<col class="field-name" />
77<col class="field-body" />
78<tbody valign="top">
79<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./metafunction-class.html">Metafunction Class</a>.</td>
80</tr>
81<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">If <tt class="literal"><span class="pre">x</span></tt> is a <a class="reference" href="./placeholder-expression.html">Placeholder Expression</a> in a general form <tt class="literal"><span class="pre">X&lt;a1,...an&gt;</span></tt>, where
82<tt class="literal"><span class="pre">X</span></tt> is a class template and <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt> are arbitrary types, equivalent
83to</p>
84<pre class="literal-block">
85typedef <a href="./protect.html" class="identifier">protect</a>&lt; <a href="./bind.html" class="identifier">bind</a>&lt;
86      <a href="./quote.html" class="identifier">quote</a><em>n</em>&lt;X&gt;
87    , <a href="./lambda.html" class="identifier">lambda</a>&lt;a1&gt;::type,<em>...</em> <a href="./lambda.html" class="identifier">lambda</a>&lt;a<em>n</em>&gt;::type
88    &gt; &gt; f;
89</pre>
90<p class="last">otherwise, <tt class="literal"><span class="pre">f</span></tt> is identical to <tt class="literal"><span class="pre">x</span></tt>.</p>
91</td>
92</tr>
93</tbody>
94</table>
95<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
96<pre class="literal-block">
97typedef <a href="./lambda.html" class="identifier">lambda</a>&lt;x,tag&gt;::type f;
98</pre>
99<table class="field-list" frame="void" rules="none">
100<col class="field-name" />
101<col class="field-body" />
102<tbody valign="top">
103<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./metafunction-class.html">Metafunction Class</a>.</td>
104</tr>
105<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">If <tt class="literal"><span class="pre">x</span></tt> is a <a class="reference" href="./placeholder-expression.html">Placeholder Expression</a> in a general form <tt class="literal"><span class="pre">X&lt;a1,...an&gt;</span></tt>, where
106<tt class="literal"><span class="pre">X</span></tt> is a class template and <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt> are arbitrary types, equivalent
107to</p>
108<pre class="literal-block">
109typedef <a href="./protect.html" class="identifier">protect</a>&lt; <a href="./bind.html" class="identifier">bind</a>&lt;
110      <a href="./quote.html" class="identifier">quote</a><em>n</em>&lt;X,tag&gt;
111    , <a href="./lambda.html" class="identifier">lambda</a>&lt;a1,tag&gt;::type,<em>...</em> <a href="./lambda.html" class="identifier">lambda</a>&lt;a<em>n</em>,tag&gt;::type
112    &gt; &gt; f;
113</pre>
114<p class="last">otherwise, <tt class="literal"><span class="pre">f</span></tt> is identical to <tt class="literal"><span class="pre">x</span></tt>.</p>
115</td>
116</tr>
117</tbody>
118</table>
119</div>
120<div class="section" id="lambda-example">
121<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
122<pre class="literal-block">
123template&lt; typename N1, typename N2 &gt; struct int_plus
124    : <a href="./int.html" class="identifier">int_</a>&lt;( N1::value + N2::value )&gt;
125{
126};
127
128typedef <a href="./lambda.html" class="identifier">lambda</a>&lt; int_plus&lt;_1, <a href="./int.html" class="identifier">int_</a>&lt;42&gt; &gt; &gt;::type f1;
129typedef <a href="./bind.html" class="identifier">bind</a>&lt; <a href="./quote.html" class="identifier">quote</a><tt class="literal"><span class="pre">2</span></tt>&lt;int_plus&gt;, _1, <a href="./int.html" class="identifier">int_</a>&lt;42&gt; &gt; f2;
130
131typedef f1::<a href="./apply.html" class="identifier">apply</a>&lt;42&gt;::type r1;
132typedef f2::<a href="./apply.html" class="identifier">apply</a>&lt;42&gt;::type r2;
133
134<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r1::value, ==, 84 );
135<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r2::value, ==, 84 );
136</pre>
137</div>
138<div class="section" id="composition-lambda-see-also">
139<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
140<p><a class="reference" href="./composition-and-argument.html">Composition and Argument Binding</a>, <a class="reference" href="./invocation.html">invocation</a>, <a class="reference" href="./placeholders.html">Placeholders</a>, <a class="refentry reference" href="./bind.html"><tt class="refentry literal"><span class="pre">bind</span></tt></a>, <a class="refentry reference" href="./quote.html"><tt class="refentry literal"><span class="pre">quote</span></tt></a>, <a class="refentry reference" href="./protect.html"><tt class="refentry literal"><span class="pre">protect</span></tt></a>, <a class="refentry reference" href="./apply.html"><tt class="refentry literal"><span class="pre">apply</span></tt></a></p>
141<!-- modtime: November 13, 2004 02:51:02 +0000 -->
142<!-- Metafunctions/Composition and Argument Binding//bind |30 -->
143</div>
144</div>
145
146<div class="footer-separator"></div>
147<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./placeholders.html" class="navigation-link">Prev</a>&nbsp;<a href="./bind.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./placeholders.html" class="navigation-link">Back</a>&nbsp;<a href="./bind.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
148</tr></table></body>
149</html>
Note: See TracBrowser for help on using the repository browser.