Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 623999701586b0ea103ff2ccad7954a6 > files > 8908

boost-doc-1.44.0-1.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
  <meta http-equiv="Content-Language" content="en-us">
  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  <link href="../pool.css" rel="stylesheet" type="text/css">

  <title>ct_gcd_lcm - Compile-Time GCD and LCM</title>
</head>

<body>
  <img src="../../../../boost.png" width="276" height="86" alt="C++ Boost">

  <h1 align="center">ct_gcd_lcm - Compile-Time GCD and LCM</h1>

  <h2>Introduction</h2>

  <p>detail/ct_gcd_lcm.hpp provides two compile-time algorithms: greatest
  common divisor and least common multiple.</p>

  <h2>Synopsis</h2>
  <pre class="code">
namespace details {
namespace pool {

template &lt;unsigned A, unsigned B&gt;
struct ct_gcd
{
  static const unsigned value = ...;
};
template &lt;unsigned A, unsigned B&gt;
struct ct_lcm
{
  static const unsigned value = ...;
};

} // namespace pool
} // namespace details
</pre>

  <h2>Semantics</h2>

  <table align="center" border summary="">
    <caption>
      <em>Symbol Table</em>
    </caption>

    <tr>
      <th>Symbol</th>

      <th>Meaning</th>
    </tr>

    <tr>
      <td class="code">A, B</td>

      <td>compile-time unsigned integer constants<a href=
      "#s519p1"><sup>[5.19/1]</sup></a></td>
    </tr>
  </table><br>

  <table align="center" border summary="">
    <caption>
      <em>Semantics</em>
    </caption>

    <tr>
      <th>Expression</th>

      <th>Result Type</th>

      <th>Value</th>

      <th>Precondition</th>
    </tr>

    <tr>
      <td class="code">ct_gcd&lt;A, B&gt;::value</td>

      <td>compile-time unsigned integer constant</td>

      <td>The greatest common divisor of <span class="code">A</span> and
      <span class="code">B</span></td>

      <td class="code">A != 0 &amp;&amp; B != 0</td>
    </tr>

    <tr>
      <td class="code">ct_lcm&lt;A, B&gt;::value</td>

      <td>compile-time unsigned integer constant</td>

      <td>The least common multiple of <span class="code">A</span> and
      <span class="code">B</span></td>

      <td class="code">A != 0 &amp;&amp; B != 0</td>
    </tr>
  </table>

  <h2>Notes</h2>

  <p>Since these are compile-time algorithms, violation of the preconditions
  will result in a compile-time error.</p>

  <h2>Dependencies</h2>

  <ul>
    <li>&lt;boost/static_assert.hpp&gt; (see <a href=
    "../../../static_assert/static_assert.htm">Boost.Static_Assert</a>), to
    ensure preconditions are met.</li>

    <li>&lt;boost/type_traits/ice.hpp&gt; (see <a href=
    "http://www.boost.org/more/int_const_guidelines.htm">Coding Guidelines for
    Integral Constant Expressions</a>), to help with portability.</li>
  </ul>

  <h2>Selected Quotations from the Standard</h2>

  <p><a name="s519p1" id="s519p1"></a><strong>5.19/1: Expressions: Constant
  Expressions:</strong> ". . . An <em>integral constant expression</em> can
  involve only literals (2.13), enumerators, <span class="code">const</span>
  variables or static data members of integral or enumeration types
  initialized with constant expressions (8.5), non-type template parameters
  of integral or enumeration types, and <span class="code">sizeof</span>
  expressions. Floating literals (2.13.3) can appear only if they are cast to
  integral or enumeration types. Only type conversions to integral or
  enumeration types can be used. In particular, except in <span class=
  "code">sizeof</span> expressions, functions, class objects, pointers, or
  references shall not be used, and assignment, increment, decrement,
  function-call, or comma operators shall not be used."</p>

  <h2>Future Directions</h2>

  <p>This header may be replaced by a Boost compile-time algorithms
  library.</p>
  <hr>

  <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
  "../../../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
  height="31" width="88"></a></p>

  <p>Revised 
  <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
  December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>

  <p><i>Copyright &copy; 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT
  com)</i></p>

  <p><i>Distributed under the Boost Software License, Version 1.0. (See
  accompanying file <a href="../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
  or copy at <a href=
  "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
</body>
</html>