safe_range.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.1//EN"
  3. "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
  4. <section id="safe_numerics.safe_range">
  5. <title>safe_signed_range&lt;MIN, MAX, PP, EP&gt; and
  6. safe_unsigned_range&lt;MIN, MAX, PP, EP&gt;</title>
  7. <?dbhtml stop-chunking?>
  8. <section>
  9. <title>Description</title>
  10. <para>This type holds a signed or unsigned integer in the closed range
  11. [MIN, MAX]. A <code>safe_signed_range&lt;MIN, MAX, PP, EP&gt;</code> or
  12. <code>safe_unsigned_range&lt;MIN, MAX, PP, EP&gt;</code> can be used
  13. anywhere an arithmetic type is permitted. Any expression which uses either
  14. of these types is guaranteed to return an arithmetically correct value or
  15. to trap in some way.</para>
  16. </section>
  17. <section>
  18. <title>Notation</title>
  19. <informaltable>
  20. <tgroup cols="2">
  21. <colspec align="left" colwidth="1*"/>
  22. <colspec align="left" colwidth="8*"/>
  23. <thead>
  24. <row>
  25. <entry align="left">Symbol</entry>
  26. <entry align="left">Description</entry>
  27. </row>
  28. </thead>
  29. <tbody>
  30. <row>
  31. <entry><code>MIN, MAX</code></entry>
  32. <entry>Minimum and maximum values that the range can
  33. represent.</entry>
  34. </row>
  35. </tbody>
  36. </tgroup>
  37. </informaltable>
  38. </section>
  39. <section>
  40. <title>Associated Types</title>
  41. <informaltable>
  42. <tgroup cols="2">
  43. <colspec align="left" colwidth="1*"/>
  44. <colspec align="left" colwidth="8*"/>
  45. <tbody>
  46. <row>
  47. <entry><code>PP</code></entry>
  48. <entry>Promotion Policy. A type which specifies the result type of
  49. an expression using safe types.</entry>
  50. </row>
  51. <row>
  52. <entry><code>EP</code></entry>
  53. <entry>Exception Policy. A type containing members which are
  54. called when a correct result cannot be returned</entry>
  55. </row>
  56. </tbody>
  57. </tgroup>
  58. </informaltable>
  59. </section>
  60. <section>
  61. <title>Template Parameters</title>
  62. <informaltable>
  63. <tgroup cols="3">
  64. <colspec align="left" colwidth="1*"/>
  65. <colspec align="left" colwidth="2*"/>
  66. <colspec align="left" colwidth="6*"/>
  67. <thead>
  68. <row>
  69. <entry align="left">Parameter</entry>
  70. <entry align="left">Requirements</entry>
  71. <entry>Description</entry>
  72. </row>
  73. </thead>
  74. <tbody>
  75. <row>
  76. <entry><code>MIN</code></entry>
  77. <entry>must be a non-negative literal</entry>
  78. <entry>The minimum non-negative integer value that this type may
  79. hold</entry>
  80. </row>
  81. <row>
  82. <entry><code>MAX</code></entry>
  83. <entry>must be a non-negative literal</entry>
  84. <entry>The maximum non-negative integer value that this type may
  85. hold</entry>
  86. </row>
  87. <row>
  88. <entry/>
  89. <entry>MIN &lt;= MAX</entry>
  90. <entry>must be a valid closed range</entry>
  91. </row>
  92. <row>
  93. <entry><code>PP</code></entry>
  94. <entry><link linkend="safe_numerics.numeric"><link
  95. linkend="safe_numerics.promotion_policy">PromotionPolicy&lt;PP&gt;</link></link></entry>
  96. <entry><para>Default value is <link
  97. linkend="safe_numerics.promotion_policies.native"><code>boost::numeric::native</code></link></para></entry>
  98. </row>
  99. <row>
  100. <entry><code>EP</code></entry>
  101. <entry><link linkend="safe_numerics.numeric"><link
  102. linkend="safe_numerics.exception_policy">Exception
  103. Policy&lt;EP&gt;</link></link></entry>
  104. <entry><para>Default value is <link
  105. linkend="safe_numerics.exception_policies.default_exception_policy"><code>boost::numeric::default_exception_policy</code></link></para></entry>
  106. </row>
  107. </tbody>
  108. </tgroup>
  109. </informaltable>
  110. </section>
  111. <section>
  112. <title>Model of</title>
  113. <para><link linkend="safe_numerics.numeric">Integer</link></para>
  114. <para><link
  115. linkend="safe_numerics.safe_numeric_concept">SafeNumeric</link></para>
  116. </section>
  117. <section>
  118. <title>Valid Expressions</title>
  119. <para>Implements all expressions and only those expressions defined by the
  120. <link linkend="safe_numerics.safe_numeric_concept">SafeNumeric</link> type
  121. requirements. Thus, the result type of such an expression will be another
  122. safe type. The actual type of the result of such an expression will depend
  123. upon the specific promotion policy template parameter.</para>
  124. </section>
  125. <section>
  126. <title>Example of use</title>
  127. <programlisting><xi:include href="../../example/example19.cpp"
  128. parse="text" xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
  129. </section>
  130. <section>
  131. <title>Header</title>
  132. <para><filename><ulink
  133. url="../../include/boost/safe_numerics/safe_integer_range.hpp">#include
  134. &lt;boost/numeric/safe_numerics/safe_range.hpp&gt;</ulink></filename></para>
  135. </section>
  136. </section>