Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/doc/tutorial/apply-lambda-semantics.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 6.1 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<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" />
7<title>THE BOOST MPL LIBRARY: apply/lambda Semantics</title>
8<link rel="stylesheet" href="../style.css" type="text/css" />
9</head>
10<body class="docframe">
11<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./changes-in-boost-1-32-0.html" class="navigation-link">Prev</a>&nbsp;<a href="./iterator-protocol.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./iterator-protocol.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./changes-in-boost-1-32-0.html" class="navigation-link">Up</a>&nbsp;<a href="../index.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./tutorial_toc.html" class="navigation-link">Full TOC</a></span></td>
12<td class="header-group page-location"><a href="../index.html" class="navigation-link">Front Page</a> / <a href="./changelog-history.html" class="navigation-link">Changelog & History</a> / <a href="./changes-in-boost-1-32-0.html" class="navigation-link">Changes in Boost 1.32.0 Release</a> / <a href="./apply-lambda-semantics.html" class="navigation-link">apply/lambda Semantics</a></td>
13</tr></table><div class="header-separator"></div>
14<div class="section" id="apply-lambda-semantics">
15<h1><a class="toc-backref" href="./changes-in-boost-1-32-0.html#id64" name="apply-lambda-semantics"><tt class="literal"><span class="pre">apply</span></tt>/<tt class="literal"><span class="pre">lambda</span></tt> Semantics</a></h1>
16<ol class="arabic">
17<li><p class="first">Nullary metafunction classes are now consistent with all other
18metafunction classes, rather than being identical to nullary
19metafunctions:</p>
20<table border="1" class="table">
21<colgroup>
22<col width="37%" />
23<col width="22%" />
24<col width="40%" />
25</colgroup>
26<thead valign="bottom">
27<tr><th><p class="first last">Nullary...</p>
28</th>
29<th><p class="first last">Before</p>
30</th>
31<th><p class="first last">Now</p>
32</th>
33</tr>
34</thead>
35<tbody valign="top">
36<tr><td><p class="first last">Metafunction</p>
37</td>
38<td><p class="first last"><tt class="literal"><span class="pre">f::type</span></tt></p>
39</td>
40<td><p class="first last"><tt class="literal"><span class="pre">f::type</span></tt></p>
41</td>
42</tr>
43<tr><td><p class="first last">Metafunction class</p>
44</td>
45<td><p class="first last"><tt class="literal"><span class="pre">c::type</span></tt></p>
46</td>
47<td><p class="first last"><tt class="literal"><span class="pre">c::apply&lt;&gt;::type</span></tt> or
48<tt class="literal"><span class="pre">c::apply::type</span></tt> <a class="footnote-reference" href="#id21" id="id20" name="id20">[7]</a></p>
49</td>
50</tr>
51</tbody>
52</table>
53<p>This fixes a flaw in the metafunction class/metafunction algebra
54that long has been a major source of other inconsistencies throughout
55the library.</p>
56</li>
57<li><p class="first">The <tt class="literal"><span class="pre">apply</span></tt> metafunction now automatically invokes <tt class="literal"><span class="pre">lambda</span></tt>
58on its first argument.  For example, the following is well-formed now:</p>
59<pre class="literal-block">
60typedef apply&lt; plus&lt;_1,_1&gt;, int_&lt;2&gt; &gt;::type four;
61</pre>
62<p><tt class="literal"><span class="pre">apply_wrap</span></tt><em>n</em> auxiliary metafunctions are available for rare cases
63when it's crucial to eliminate the small overhead associated with lambda
64expressions while still avoiding various compiler bugs known to
65cause problems with
66the obvious <tt class="literal"><span class="pre">f::template</span> <span class="pre">apply&lt;...&gt;::type</span></tt> syntax.</p>
67</li>
68<li><p class="first">The <tt class="literal"><span class="pre">lambda</span></tt> implementation for broken compilers has been
69reworked to emulate the semantics of the full-fledged version
70as closely as possible; consequently, any code out there that
71was taking advantage of the semantic quirks of less complete
72emulation in the previous release may stop working with the new
73one.</p>
74</li>
75</ol>
76<p>To get a detailed picture of the new apply/lambda semantics, please
77see the test case at
78<a class="reference" href="http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/mpl/test/apply.cpp?view=markup" target="_top">http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/mpl/test/apply.cpp?view=markup</a>
79and the corresponding sections of the MPL <a class="reference" href="./reference-manual.html">reference manual</a>.</p>
80<table class="footnote" frame="void" id="id21" rules="none">
81<colgroup><col class="label" /><col /></colgroup>
82<tbody valign="top">
83<tr><td class="label"><a class="fn-backref" href="#id20" name="id21">[7]</a></td><td>The second form is available only on fully conforming compilers.</td></tr>
84</tbody>
85</table>
86</div>
87
88<div class="footer-separator"></div>
89<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./changes-in-boost-1-32-0.html" class="navigation-link">Prev</a>&nbsp;<a href="./iterator-protocol.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group">Back&nbsp;<a href="./iterator-protocol.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./changes-in-boost-1-32-0.html" class="navigation-link">Up</a>&nbsp;<a href="../index.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./tutorial_toc.html" class="navigation-link">Full TOC</a></span></td>
90</tr></table></body>
91</html>
Note: See TracBrowser for help on using the repository browser.