123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.1//EN"
- "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
- <section id="safe_numerics.integer">
- <title>Integer<T></title>
- <?dbhtml stop-chunking?>
- <section>
- <title>Description</title>
- <para>A type fulfills the requirements of an Integer if it has the
- properties of a integer.</para>
- <para>More specifically, a type T is Integer if there exists a
- specialization of <code>std::numeric_limits<T> for which
- std::numeric_limits<T>::is_integer</code> is equal to
- <code>true</code>. See the documentation for standard library class
- <code>numeric_limits</code>. The standard library includes such
- specializations for all built-in numeric types. Note that this concept is
- distinct from the C++ standard library type traits
- <code>is_integral</code> and <code>is_arithmetic</code>. These latter
- fulfill the requirements of the concept Numeric. But there are types which
- fulfill this concept for which <code>is_arithmetic<T>::value ==
- false</code>. For example see <code>safe<int></code>.</para>
- </section>
- <section>
- <title>Refinement of</title>
- <para><link linkend="safe_numerics.numeric">Numeric</link></para>
- </section>
- <section>
- <title>Notation</title>
- <informaltable>
- <tgroup cols="2" colsep="1" rowsep="1">
- <colspec align="left" colwidth="2*"/>
- <colspec align="left" colwidth="4*"/>
- <tbody>
- <row>
- <entry><code>T, U, V</code></entry>
- <entry>A type that is a model of the Integer</entry>
- </row>
- <row>
- <entry><code>t, u</code></entry>
- <entry>An object of type modeling Integer</entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable>
- </section>
- <section>
- <title>Valid Expressions</title>
- <para>In addition to the expressions defined in <link
- linkend="safe_numerics.numeric">Numeric</link> the following expressions
- must be valid. <table>
- <title>General</title>
- <tgroup cols="2">
- <colspec align="left" colwidth="2*"/>
- <colspec align="left" colwidth="4*"/>
- <thead>
- <row>
- <entry align="left">Expression</entry>
- <entry>Value</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><code>std::numeric_limits<T>::is_integer</code></entry>
- <entry>true</entry>
- </row>
- </tbody>
- </tgroup>
- </table><informaltable>
- <tgroup cols="3">
- <colspec align="left" colwidth="1*"/>
- <colspec align="left" colwidth="1*"/>
- <colspec align="left" colwidth="4*"/>
- <thead>
- <row>
- <entry align="left">Expression</entry>
- <entry>Return Type</entry>
- <entry>Semantics</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><code>~t</code></entry>
- <entry><code>T</code></entry>
- <entry>bitwise complement</entry>
- </row>
- <row>
- <entry><code>t << u</code></entry>
- <entry><code>T</code></entry>
- <entry>shift t left u bits</entry>
- </row>
- <row>
- <entry><code>t >> u</code></entry>
- <entry><code>T</code></entry>
- <entry>shift t right by u bits</entry>
- </row>
- <row>
- <entry><code>t & u</code></entry>
- <entry><code>V</code></entry>
- <entry>and of t and u padded out to max # bits in t, u</entry>
- </row>
- <row>
- <entry><code>t | u</code></entry>
- <entry><code>V</code></entry>
- <entry>or of t and u padded out to max # bits in t, u</entry>
- </row>
- <row>
- <entry><code>t ^ u</code></entry>
- <entry><code>V</code></entry>
- <entry>exclusive or of t and u padded out to max # bits in t,
- u</entry>
- </row>
- <row>
- <entry><code>t <<= u</code></entry>
- <entry><code>T</code></entry>
- <entry>left shift the value of t by u bits</entry>
- </row>
- <row>
- <entry><code>t >>= u</code></entry>
- <entry><code>T</code></entry>
- <entry>right shift the value of t by u bits</entry>
- </row>
- <row>
- <entry><code>t &= u</code></entry>
- <entry><code>T</code></entry>
- <entry>and the value of t with u and assign to t</entry>
- </row>
- <row>
- <entry><code>t |= u</code></entry>
- <entry><code>T</code></entry>
- <entry>or the value of t with u and assign to t</entry>
- </row>
- <row>
- <entry><code>t ^= u</code></entry>
- <entry><code>T</code></entry>
- <entry>exclusive or the value of t with u and assign to
- t</entry>
- </row>
- </tbody>
- </tgroup>
- </informaltable></para>
- </section>
- <section>
- <title>Models</title>
- <para><code>int, safe<int>, safe_unsigned_range<0, 11>,
- checked_result<int> etc.</code></para>
- </section>
- <section>
- <title>Header</title>
- <para><ulink
- url="../../include/boost/safe_numerics/concept/numeric.hpp"><code>#include
- <boost/safe_numerics/concepts/integer.hpp> </code></ulink></para>
- </section>
- </section>
|