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