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