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) -->
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: Numeric Metafunction Protocol/Infrastructure
</title>
11 <link rel=
"stylesheet" href=
"../style.css" type=
"text/css" />
13 <body class=
"docframe">
14 <table class=
"header"><tr class=
"header"><td class=
"header-group navigation-bar"><span class=
"navigation-group"><a href=
"./tag-dispatching-protocol.html" class=
"navigation-link">Prev
</a> <a href=
"./renaming-cleanup.html" class=
"navigation-link">Next
</a></span><span class=
"navigation-group-separator"> |
</span><span class=
"navigation-group"><a href=
"./tag-dispatching-protocol.html" class=
"navigation-link">Back
</a> <a href=
"./renaming-cleanup.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=
"./numeric-metafunction.html" class=
"navigation-link">Numeric Metafunction Protocol/Infrastructure
</a></td>
16 </tr></table><div class=
"header-separator"></div>
17 <div class=
"section" id=
"numeric-metafunction">
18 <h1><a class=
"toc-backref" href=
"./changes-in-boost-1-32-0.html#id67" name=
"numeric-metafunction">Numeric Metafunction Protocol/Infrastructure
</a></h1>
19 <p>The arithmetic, comparison and bitwise metafunctions are now
20 <cite>polymorphic
</cite>, and can operate on a variety of numeric types,
21 including rational, fixed-point and complex numbers. They allow
22 <cite>mixed arithmetic
</cite>, meaning that you can perform an operation on
23 arguments of different types, and the result will yield the
24 largest/most general of the argument types. The infrastructure
25 allows user-defined numeric types to be freely intermixed with
26 predefined library types. See
27 <a class=
"reference" href=
"../../test/numeric_ops.cpp" target=
"_top">libs/mpl/test/numeric_ops.cpp
</a>
28 for an illustrative example, and the
<a class=
"reference" href=
"./reference-manual.html">reference manual
</a> for
29 the formal infrastructure specification.
</p>
30 <p>If you were using MPL numeric metafunctions on your own integral
31 wrapper class similar to
<tt class=
"literal"><span class=
"pre">mpl::int_
</span></tt>, you can plug your class
32 into the new infrastructure by extending it with the following
34 <pre class=
"literal-block">
35 typedef mpl::integral_c_tag tag;
38 <table border=
"1" class=
"table">
43 <thead valign=
"bottom">
49 <tr><td><pre class=
"first last literal-block">
50 template
< int n
> struct my_int
52 static int const value = n;
57 <td><pre class=
"first last literal-block">
58 template
< int n
> struct my_int
60 <strong>typedef mpl::integral_c_tag tag;
</strong>
61 static int const value = n;
71 <div class=
"footer-separator"></div>
72 <table class=
"footer"><tr class=
"footer"><td class=
"header-group navigation-bar"><span class=
"navigation-group"><a href=
"./tag-dispatching-protocol.html" class=
"navigation-link">Prev
</a> <a href=
"./renaming-cleanup.html" class=
"navigation-link">Next
</a></span><span class=
"navigation-group-separator"> |
</span><span class=
"navigation-group"><a href=
"./tag-dispatching-protocol.html" class=
"navigation-link">Back
</a> <a href=
"./renaming-cleanup.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>