Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/doc/refmanual/metafunctions.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: 7.8 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: Metafunctions</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="./reverse-stable-partition.html" class="navigation-link">Prev</a>&nbsp;<a href="./metafunctions-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms.html" class="navigation-link">Back</a>&nbsp;<a href="./data-types.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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></td>
16</tr></table><div class="header-separator"></div>
17<div class="section" id="metafunctions">
18<h1><a class="toc-backref" href="../refmanual.html#id436" name="metafunctions">Metafunctions</a></h1>
19<a class="target" id="label-metafunctions" name="label-metafunctions"></a><p>The MPL includes a number of predefined metafunctions that can be roughly
20classified in two categories: <cite>general purpose metafunctions</cite>, dealing with
21conditional <a class="reference" href="./type-selection.html">type selection</a> and higher-order metafunction <a class="reference" href="./invocation.html">invocation</a>,
22<a class="reference" href="./composition-and-argument.html">composition</a>, and <a class="reference" href="./composition-and-argument.html">argument binding</a>, and <cite>numeric metafunctions</cite>,
23incapsulating built-in and user-defined <a class="reference" href="./arithmetic-operations.html">arithmetic</a>, <a class="reference" href="./comparisons.html">comparison</a>,
24<a class="reference" href="./logical-operations.html">logical</a>, and <a class="reference" href="./bitwise-operations.html">bitwise</a> operations.</p>
25<p>Given that it is possible to perform integer numeric computations at
26compile time using the conventional operators notation, the need for the
27second category might be not obvious, but it in fact plays a cental role in
28making programming with MPL seemingly effortless. In
29particular, there are at least two contexts where built-in language
30facilities fall short <a class="footnote-reference" href="#portability" id="id200" name="id200">[3]</a>:</p>
31<ol class="arabic simple">
32<li>Passing a computation to an algorithm.</li>
33<li>Performing a computation on non-integer data.</li>
34</ol>
35<p>The second use case deserves special attention. In contrast to the built-in,
36strictly integer compile-time arithmetics, the MPL numeric metafunctions are
37<em>polymorphic</em>, with support for <em>mixed-type arithmetics</em>. This means that they
38can operate on a variety of numeric types — for instance, rational,
39fixed-point or complex numbers, — and that, in general, you are allowed to
40freely intermix these types within a single expression. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept for more details on the MPL numeric infrastructure.</p>
41<!-- The provided `infrastructure`__ allows easy plugging of user-defined numeric
42types
43Naturally, they also , meaning that you can perform a computation on the
44arguments of different types, and the result will yeild the largest/most general
45of them. For user-defined numeric types, they provide an `infrastructure`__ that
46allows easy plugging and seemless integration with predefined library
47types. details.
48
49__ `Numeric Metafunction`_ -->
50<p>To reduce a negative syntactical impact of the metafunctions notation
51over the infix operator notation, all numeric metafunctions
52allow to pass up to N arguments, where N is defined by the value of
53<a class="refentry reference" href="./limit-metafunction-arity.html"><tt class="refentry literal"><span class="pre">BOOST_MPL_LIMIT_METAFUNCTION_ARITY</span></tt></a> configuration macro.</p>
54<table class="footnote" frame="void" id="portability" rules="none">
55<colgroup><col class="label" /><col /></colgroup>
56<tbody valign="top">
57<tr><td class="label"><a class="fn-backref" href="#id200" name="portability">[3]</a></td><td>All other considerations aside, as of the time of this writing
58(early 2004), using built-in operators on integral constants still often
59present a portability problem — many compilers cannot handle particular
60forms of expressions, forcing us to use conditional compilation. Because MPL
61numeric metafunctions work on types and encapsulate these kind of workarounds
62internally, they elude these problems, so if you aim for portability, it is
63generally adviced to use them in the place of the conventional operators, even
64at the price of slightly decreased readability.</td></tr>
65</tbody>
66</table>
67<!-- modtime: November 04, 2004 09:37:30 +0000 -->
68<ul class="toc simple" id="outline">
69<li><a class="reference" href="./metafunctions-concepts.html" id="id437" name="id437">Concepts</a></li>
70<li><a class="reference" href="./type-selection.html" id="id445" name="id445">Type Selection</a></li>
71<li><a class="reference" href="./invocation.html" id="id450" name="id450">Invocation</a></li>
72<li><a class="reference" href="./composition-and-argument.html" id="id454" name="id454">Composition and Argument Binding</a></li>
73<li><a class="reference" href="./arithmetic-operations.html" id="id461" name="id461">Arithmetic Operations</a></li>
74<li><a class="reference" href="./comparisons.html" id="id468" name="id468">Comparisons</a></li>
75<li><a class="reference" href="./logical-operations.html" id="id475" name="id475">Logical Operations</a></li>
76<li><a class="reference" href="./bitwise-operations.html" id="id479" name="id479">Bitwise Operations</a></li>
77<li><a class="reference" href="./trivial.html" id="id485" name="id485">Trivial</a></li>
78<li><a class="reference" href="./miscellaneous.html" id="id487" name="id487">Miscellaneous</a></li>
79</ul>
80</div>
81
82<div class="footer-separator"></div>
83<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./reverse-stable-partition.html" class="navigation-link">Prev</a>&nbsp;<a href="./metafunctions-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./algorithms.html" class="navigation-link">Back</a>&nbsp;<a href="./data-types.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.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>
84</tr></table></body>
85</html>
Note: See TracBrowser for help on using the repository browser.