Files
mpl/doc/ref/Reference/rational_c.html
Rene Rivera 9f515e90a6 Fix broken links.
[SVN r21400]
2003-12-27 01:05:33 +00:00

72 lines
3.0 KiB
HTML

<!doctype html public "-//ietf//dtd html//en">
<html><head><title>boost::mpl::rational_c</title>
<link rel="stylesheet" href="../mpl_wiki.css">
</head><body bgcolor="white">
<h1><a href="../Table_of_Contents.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>rational_c</h1><h3>Synopsis</h3>
<p>
<pre>
template&lt;
typename IntegerType
, IntegerType N
, IntegerType D = 1
&gt;
struct rational_c
{
typedef rational_c&lt;IntegerType, N, D&gt; type;
typedef IntegerType integer_type;
typedef integral_c&lt;IntegerType,N&gt; numerator;
typedef integral_c&lt;IntegerType,D&gt; denominator;
<p>
static double value();
};
</pre>
<p>
<p>
<h3>Description</h3>
<p>
A model of <a href="../Rational_Constant.html">Rational Constant</a>.
<p>
<h3>Definition</h3>
<p>
<pre>
#include "<a href="../../../../../boost/mpl/math/rational_c.hpp">boost/mpl/math/rational_c.hpp</a>"
</pre>
<p>
<h3>Parameters</h3>
<table border="1">
<tr><th>&nbsp;Parameter&nbsp;</th><th>&nbsp;Requirement&nbsp;</th><th>&nbsp;Description &nbsp;</th></tr>
<tr><td><code>IntegerType</code></td><td>An integral type</td><td>Type used to represent numerator and denominator. </td></tr>
<tr><td><code>N</code></td><td>A compile time integral constant of type <code>IntegerType</code></td><td>Value of numerator. </td></tr>
<tr><td><code>D</code></td><td>A compile time integral constant of type <code>IntegerType</code></td><td>Value of denominator. </td></tr>
</table>
<p>
<h3>Expression semantics</h3>
<p>
<table border="1">
<tr><th>&nbsp;Expression&nbsp;</th><th>&nbsp;Expression&nbsp;type&nbsp;</th><th>&nbsp;Precondition&nbsp;</th><th>&nbsp;Semantics&nbsp;</th><th>&nbsp;Postcondition&nbsp;</th></tr>
<tr><td><code>rational_c&lt;T,n,d&gt;::value()</code></td><td><code>double</code></td><td><code>static_cast&lt;T&gt;(d) != 0</code></td><td>Returns <code>static_cast&lt;double&gt;(static_cast&lt;T&gt;(n)) / static_cast&lt;T&gt;(d)</code>.</td><td></td></tr>
</table>
<p>
<h3>Complexity</h3>
<p>
All operations take amortized constant time.
<p>
<h3>Example</h3>
<p>
<pre>
typedef <a href="../Reference/rational_c.html">rational_c</a>&lt;int,1,2&gt; half;
typedef <a href="../Reference/rational_c.html">rational_c</a>&lt;int,2,4&gt; half_2;
typedef <a href="../Reference/rational_c.html">rational_c</a>&lt;long,9,15&gt; three_fiths_3;
typedef rational_plus&lt;three_fiths,half&gt;::type eleven_tenth;
typedef rational_plus&lt;half,half&gt;::type one;
typedef <a href="../Reference/rational_c.html">rational_c</a>&lt;long,1,8&gt; eighth;
typedef rational_minus&lt;half,eighth&gt;::type three_eighths;
typedef rational_multiplies&lt;half,eighth&gt;::type sixteenth;
typedef rational_divides&lt;eighth,half&gt;::type quarter;
</pre>
<p>
<h3>See also</h3>
<p>
<a href="../Rational_Constant.html">Rational Constant</a>, <a href="../Integral_Constant.html">Integral Constant</a>, <code>integral_c</code>
<p><hr>
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited October 30, 2003 2:44 am</body></html>