1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Chapter 34. Boost.Ratio 2.1.0</title> 6<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)"> 10<link rel="prev" href="boost_random/history_and_acknowledgements.html" title="History and Acknowledgements"> 11<link rel="next" href="ratio/users_guide.html" title="User's Guide"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td> 16<td align="center"><a href="../../index.html">Home</a></td> 17<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="boost_random/history_and_acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ratio/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="chapter"> 27<div class="titlepage"><div> 28<div><h2 class="title"> 29<a name="ratio"></a>Chapter 34. Boost.Ratio 2.1.0</h2></div> 30<div><div class="author"><h3 class="author"> 31<span class="firstname">Howard</span> <span class="surname">Hinnant</span> 32</h3></div></div> 33<div><div class="author"><h3 class="author"> 34<span class="firstname">Beman</span> <span class="surname">Dawes</span> 35</h3></div></div> 36<div><div class="author"><h3 class="author"> 37<span class="firstname">Vicente J.</span> <span class="surname">Botet Escriba</span> 38</h3></div></div> 39<div><p class="copyright">Copyright © 2008 Howard Hinnant</p></div> 40<div><p class="copyright">Copyright © 2006, 2008 Beman Dawes</p></div> 41<div><p class="copyright">Copyright © 2009-2012 Vicente 42 J. Botet Escriba</p></div> 43<div><div class="legalnotice"> 44<a name="ratio.legal"></a><p> 45 Distributed under the Boost Software License, Version 1.0. (See accompanying 46 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 47 </p> 48</div></div> 49</div></div> 50<div class="toc"> 51<p><b>Table of Contents</b></p> 52<dl class="toc"> 53<dt><span class="section"><a href="ratio.html#ratio.overview">Overview</a></span></dt> 54<dd><dl> 55<dt><span class="section"><a href="ratio.html#ratio.overview.motivation">Motivation</a></span></dt> 56<dt><span class="section"><a href="ratio.html#ratio.overview.description">Description</a></span></dt> 57</dl></dd> 58<dt><span class="section"><a href="ratio/users_guide.html">User's Guide</a></span></dt> 59<dd><dl> 60<dt><span class="section"><a href="ratio/users_guide.html#ratio.users_guide.getting_started">Getting Started</a></span></dt> 61<dt><span class="section"><a href="ratio/users_guide.html#ratio.users_guide.tutorial">Tutorial</a></span></dt> 62<dt><span class="section"><a href="ratio/users_guide.html#ratio.users_guide.Examples">Example</a></span></dt> 63<dt><span class="section"><a href="ratio/users_guide.html#ratio.users_guide.ext_references">External Resources</a></span></dt> 64</dl></dd> 65<dt><span class="section"><a href="ratio/reference.html">Reference </a></span></dt> 66<dd><dl> 67<dt><span class="section"><a href="ratio/reference.html#ratio.reference.config_hpp">Header <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">ratio</span><span class="special">/</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code></a></span></dt> 68<dt><span class="section"><a href="ratio/reference.html#ratio.reference.std">C++0x Recommendation</a></span></dt> 69<dt><span class="section"><a href="ratio/reference.html#ratio.reference.io">Ratio I/O</a></span></dt> 70<dt><span class="section"><a href="ratio/reference.html#ratio.reference.mpl">Rational Constant</a></span></dt> 71</dl></dd> 72<dt><span class="section"><a href="ratio/appendices.html">Appendices</a></span></dt> 73<dd><dl> 74<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.history">Appendix A: History</a></span></dt> 75<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.rationale">Appendix B: Rationale</a></span></dt> 76<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.implementation">Appendix C: Implementation 77 Notes</a></span></dt> 78<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.faq">Appendix D: FAQ</a></span></dt> 79<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.acknowledgements">Appendix E: Acknowledgements</a></span></dt> 80<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.tests">Appendix F: Tests</a></span></dt> 81<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.tickets">Appendix G: Tickets</a></span></dt> 82<dt><span class="section"><a href="ratio/appendices.html#ratio.appendices.todo">Appendix H: Future Plans</a></span></dt> 83</dl></dd> 84</dl> 85</div> 86<div class="section"> 87<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 88<a name="ratio.overview"></a><a class="link" href="ratio.html#ratio.overview" title="Overview">Overview</a> 89</h2></div></div></div> 90<div class="toc"><dl class="toc"> 91<dt><span class="section"><a href="ratio.html#ratio.overview.motivation">Motivation</a></span></dt> 92<dt><span class="section"><a href="ratio.html#ratio.overview.description">Description</a></span></dt> 93</dl></div> 94<h4> 95<a name="ratio.overview.h0"></a> 96 <span class="phrase"><a name="ratio.overview.how_to_use_this_documentation"></a></span><a class="link" href="ratio.html#ratio.overview.how_to_use_this_documentation">How 97 to Use This Documentation</a> 98 </h4> 99<p> 100 This documentation makes use of the following naming and formatting conventions. 101 </p> 102<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 103<li class="listitem"> 104 Code is in <code class="computeroutput"><span class="identifier">fixed</span> <span class="identifier">width</span> 105 <span class="identifier">font</span></code> and is syntax-highlighted. 106 </li> 107<li class="listitem"> 108 Replaceable text that you will need to supply is in <em class="replaceable"><code>italics</code></em>. 109 </li> 110<li class="listitem"> 111 Free functions are rendered in the code font followed by <code class="computeroutput"><span class="special">()</span></code>, as in <code class="computeroutput"><span class="identifier">free_function</span><span class="special">()</span></code>. 112 </li> 113<li class="listitem"> 114 If a name refers to a class template, it is specified like this: <code class="computeroutput"><span class="identifier">class_template</span><span class="special"><></span></code>; 115 that is, it is in code font and its name is followed by <code class="computeroutput"><span class="special"><></span></code> 116 to indicate that it is a class template. 117 </li> 118<li class="listitem"> 119 If a name refers to a function-like macro, it is specified like this: 120 <code class="computeroutput"><span class="identifier">MACRO</span><span class="special">()</span></code>; 121 that is, it is uppercase in code font and its name is followed by <code class="computeroutput"><span class="special">()</span></code> to indicate that it is a function-like 122 macro. Object-like macros appear without the trailing <code class="computeroutput"><span class="special">()</span></code>. 123 </li> 124<li class="listitem"> 125 Names that refer to <span class="emphasis"><em>concepts</em></span> in the generic programming 126 sense are specified in CamelCase. 127 </li> 128</ul></div> 129<div class="note"><table border="0" summary="Note"> 130<tr> 131<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../doc/src/images/note.png"></td> 132<th align="left">Note</th> 133</tr> 134<tr><td align="left" valign="top"><p> 135 In addition, notes such as this one specify non-essential information that 136 provides additional background or rationale. 137 </p></td></tr> 138</table></div> 139<p> 140 Finally, you can mentally add the following to any code fragments in this document: 141 </p> 142<pre class="programlisting"><span class="comment">// Include all of Ratio files</span> 143<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">ratio</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 144<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">;</span> 145</pre> 146<div class="section"> 147<div class="titlepage"><div><div><h3 class="title"> 148<a name="ratio.overview.motivation"></a><a class="link" href="ratio.html#ratio.overview.motivation" title="Motivation">Motivation</a> 149</h3></div></div></div> 150<p> 151 <span class="bold"><strong>Boost.Ratio</strong></span> aims to implement the compile 152 time ratio facility in C++0x, as proposed in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm" target="_top"><span class="bold"><strong>N2661 - A Foundation to Sleep On</strong></span></a>. That document 153 provides background and motivation for key design decisions and is the source 154 of a good deal of information in this documentation. 155 </p> 156</div> 157<div class="section"> 158<div class="titlepage"><div><div><h3 class="title"> 159<a name="ratio.overview.description"></a><a class="link" href="ratio.html#ratio.overview.description" title="Description">Description</a> 160</h3></div></div></div> 161<p> 162 The <span class="bold"><strong>Boost.Ratio</strong></span> library provides: 163 </p> 164<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 165<li class="listitem"> 166 A class template, <a class="link" href="ratio/reference.html#ratio.reference.std.ratio_hpp.ratio" title="Class Template ratio<>"><code class="computeroutput"><span class="identifier">ratio</span></code></a>, for specifying compile 167 time rational constants such as 1/3 of a nanosecond or the number of 168 inches per meter. <a class="link" href="ratio/reference.html#ratio.reference.std.ratio_hpp.ratio" title="Class Template ratio<>"><code class="computeroutput"><span class="identifier">ratio</span></code></a> represents a compile time 169 ratio of compile time constants with support for compile time arithmetic 170 with overflow and division by zero protection. 171 </li> 172<li class="listitem"> 173 It provides a textual representation of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">ratio</span><span class="special"><</span><span class="identifier">N</span><span class="special">,</span> <span class="identifier">D</span><span class="special">></span></code> in the form of a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span></code> 174 which can be useful for I/O. 175 </li> 176<li class="listitem"> 177 Some extension related to the <a class="link" href="ratio/reference.html#ratio.reference.mpl.rational_constant" title="Rational Constant Concept">Rational 178 Constant</a> concept enabling the use of <a class="link" href="ratio/reference.html#ratio.reference.std.ratio_hpp.ratio" title="Class Template ratio<>"><code class="computeroutput"><span class="identifier">ratio</span></code></a><> in the context 179 of <span class="bold"><strong>Boost.MPL</strong></span> numeric metafunctions. 180 </li> 181</ul></div> 182</div> 183</div> 184</div> 185<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 186<td align="left"><p><small>Last revised: August 11, 2020 at 15:03:11 GMT</small></p></td> 187<td align="right"><div class="copyright-footer"></div></td> 188</tr></table> 189<hr> 190<div class="spirit-nav"> 191<a accesskey="p" href="boost_random/history_and_acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ratio/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a> 192</div> 193</body> 194</html> 195