• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Unsigned Integer Number Generators (uint_, etc.)</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Spirit 2.5.8">
8<link rel="up" href="../numeric.html" title="Numeric Generators">
9<link rel="prev" href="../numeric.html" title="Numeric Generators">
10<link rel="next" href="signed_int.html" title="Signed Integer Number Generators (int_, etc.)">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../numeric.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.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="signed_int.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="spirit.karma.reference.numeric.unsigned_int"></a><a class="link" href="unsigned_int.html" title="Unsigned Integer Number Generators (uint_, etc.)">Unsigned
28          Integer Number Generators (<code class="computeroutput"><span class="identifier">uint_</span></code>,
29          etc.)</a>
30</h5></div></div></div>
31<h6>
32<a name="spirit.karma.reference.numeric.unsigned_int.h0"></a>
33            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.description"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.description">Description</a>
34          </h6>
35<p>
36            The <code class="computeroutput"><span class="identifier">uint_generator</span></code> class
37            is the simplest among the members of the numerics package. The <code class="computeroutput"><span class="identifier">uint_generator</span></code> can generate unsigned
38            integers of arbitrary length and size. The <code class="computeroutput"><span class="identifier">uint_generator</span></code>
39            generator can be used to generate ordinary primitive C/C++ integers or
40            even user defined scalars such as bigints (unlimited precision integers)
41            if the type follows certain expression requirements (for more information
42            about the requirements, see <a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.additional_requirements">below</a>)).
43            The <code class="computeroutput"><span class="identifier">uint_generator</span></code> is
44            a template class. Template parameters fine tune its behavior.
45          </p>
46<h6>
47<a name="spirit.karma.reference.numeric.unsigned_int.h1"></a>
48            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.header"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.header">Header</a>
49          </h6>
50<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/karma/numeric/uint.hpp&gt;</span>
51<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_uint</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
52</pre>
53<p>
54            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
55          </p>
56<h6>
57<a name="spirit.karma.reference.numeric.unsigned_int.h2"></a>
58            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.namespace"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.namespace">Namespace</a>
59          </h6>
60<div class="informaltable"><table class="table">
61<colgroup><col></colgroup>
62<thead><tr><th>
63                    <p>
64                      Name
65                    </p>
66                  </th></tr></thead>
67<tbody>
68<tr><td>
69                    <p>
70                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">lit</span> <span class="comment">// alias:
71                      boost::spirit::karma::lit</span></code>
72                    </p>
73                  </td></tr>
74<tr><td>
75                    <p>
76                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">bin</span> <span class="comment">// alias:
77                      boost::spirit::karma::bin</span></code>
78                    </p>
79                  </td></tr>
80<tr><td>
81                    <p>
82                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">oct</span> <span class="comment">// alias:
83                      boost::spirit::karma::oct</span></code>
84                    </p>
85                  </td></tr>
86<tr><td>
87                    <p>
88                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">hex</span> <span class="comment">// alias:
89                      boost::spirit::karma::hex</span></code>
90                    </p>
91                  </td></tr>
92<tr><td>
93                    <p>
94                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ushort_</span> <span class="comment">//
95                      alias: boost::spirit::karma::ushort_</span></code>
96                    </p>
97                  </td></tr>
98<tr><td>
99                    <p>
100                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ulong_</span> <span class="comment">//
101                      alias: boost::spirit::karma::ulong_</span></code>
102                    </p>
103                  </td></tr>
104<tr><td>
105                    <p>
106                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">uint_</span> <span class="comment">//
107                      alias: boost::spirit::karma::uint_</span></code>
108                    </p>
109                  </td></tr>
110<tr><td>
111                    <p>
112                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">ulong_long</span> <span class="comment">//
113                      alias: boost::spirit::karma::ulong_long</span></code>
114                    </p>
115                  </td></tr>
116</tbody>
117</table></div>
118<div class="note"><table border="0" summary="Note">
119<tr>
120<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
121<th align="left">Note</th>
122</tr>
123<tr><td align="left" valign="top"><p>
124              The generators <code class="computeroutput"><span class="identifier">ulong_long</span></code>
125              and <code class="computeroutput"><span class="identifier">ulong_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
126              are only available on platforms where the preprocessor constant <code class="computeroutput"><span class="identifier">BOOST_HAS_LONG_LONG</span></code> is defined (i.e.
127              on platforms having native support for <code class="computeroutput"><span class="keyword">unsigned</span>
128              <span class="keyword">long</span> <span class="keyword">long</span></code>
129              (64 bit) unsigned integer types).
130            </p></td></tr>
131</table></div>
132<div class="note"><table border="0" summary="Note">
133<tr>
134<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
135<th align="left">Note</th>
136</tr>
137<tr><td align="left" valign="top"><p>
138              <code class="computeroutput"><span class="identifier">lit</span></code> is reused by the
139              <a class="link" href="../string.html" title="String Generators">String Generators</a>,
140              the <a class="link" href="../char.html" title="Char Generators">Character Generators</a>,
141              and the Numeric Generators. In general, a char generator is created
142              when you pass in a character, a string generator is created when you
143              pass in a string, and a numeric generator is created when you use a
144              numeric literal.
145            </p></td></tr>
146</table></div>
147<h6>
148<a name="spirit.karma.reference.numeric.unsigned_int.h3"></a>
149            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.synopsis"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.synopsis">Synopsis</a>
150          </h6>
151<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span>
152    <span class="keyword">typename</span> <span class="identifier">Num</span>
153  <span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">Radix</span><span class="special">&gt;</span>
154<span class="keyword">struct</span> <span class="identifier">uint_generator</span><span class="special">;</span>
155</pre>
156<h6>
157<a name="spirit.karma.reference.numeric.unsigned_int.h4"></a>
158            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.template_parameters"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.template_parameters">Template
159            parameters</a>
160          </h6>
161<div class="informaltable"><table class="table">
162<colgroup>
163<col>
164<col>
165<col>
166</colgroup>
167<thead><tr>
168<th>
169                    <p>
170                      Parameter
171                    </p>
172                  </th>
173<th>
174                    <p>
175                      Description
176                    </p>
177                  </th>
178<th>
179                    <p>
180                      Default
181                    </p>
182                  </th>
183</tr></thead>
184<tbody>
185<tr>
186<td>
187                    <p>
188                      <code class="computeroutput"><span class="identifier">Num</span></code>
189                    </p>
190                  </td>
191<td>
192                    <p>
193                      The numeric base type of the numeric generator.
194                    </p>
195                  </td>
196<td>
197                    <p>
198                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span></code>
199                    </p>
200                  </td>
201</tr>
202<tr>
203<td>
204                    <p>
205                      <code class="computeroutput"><span class="identifier">Radix</span></code>
206                    </p>
207                  </td>
208<td>
209                    <p>
210                      The radix base. This can be any value in the (inclusive) range
211                      from <code class="computeroutput"><span class="number">2</span></code> .. <code class="computeroutput"><span class="number">36</span></code>.
212                    </p>
213                  </td>
214<td>
215                    <p>
216                      <code class="computeroutput"><span class="number">10</span></code>
217                    </p>
218                  </td>
219</tr>
220</tbody>
221</table></div>
222<h6>
223<a name="spirit.karma.reference.numeric.unsigned_int.h5"></a>
224            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.model_of"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.model_of">Model
225            of</a>
226          </h6>
227<div class="blockquote"><blockquote class="blockquote"><p>
228              <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>
229            </p></blockquote></div>
230<div class="variablelist">
231<p class="title"><b>Notation</b></p>
232<dl class="variablelist">
233<dt><span class="term"><code class="computeroutput"><span class="identifier">num</span></code></span></dt>
234<dd><p>
235                  Numeric literal, any unsigned integer value, or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
236                  Argument</a> that evaluates to an unsigned integer value of
237                  type <code class="computeroutput"><span class="identifier">Num</span></code>
238                </p></dd>
239<dt><span class="term"><code class="computeroutput"><span class="identifier">Num</span></code></span></dt>
240<dd><p>
241                  Type of <code class="computeroutput"><span class="identifier">num</span></code>: any
242                  unsigned integer type, or in case of a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
243                  Argument</a>, its return value
244                </p></dd>
245<dt><span class="term"><code class="computeroutput"><span class="identifier">Radix</span></code></span></dt>
246<dd><p>
247                  An integer literal specifying the required radix for the output
248                  conversion. Valid values are from the (inclusive) range <code class="computeroutput"><span class="number">2</span></code> .. <code class="computeroutput"><span class="number">36</span></code>.
249                </p></dd>
250</dl>
251</div>
252<h6>
253<a name="spirit.karma.reference.numeric.unsigned_int.h6"></a>
254            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.expression_semantics"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.expression_semantics">Expression
255            Semantics</a>
256          </h6>
257<p>
258            Semantics of an expression is defined only where it differs from, or
259            is not defined in <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>.
260          </p>
261<div class="informaltable"><table class="table">
262<colgroup>
263<col>
264<col>
265</colgroup>
266<thead><tr>
267<th>
268                    <p>
269                      Expression
270                    </p>
271                  </th>
272<th>
273                    <p>
274                      Semantics
275                    </p>
276                  </th>
277</tr></thead>
278<tbody>
279<tr>
280<td>
281                    <p>
282                      <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
283                    </p>
284                  </td>
285<td>
286                    <p>
287                      Generate the unsigned integer literal <code class="computeroutput"><span class="identifier">num</span></code>
288                      using the default formatting (radix is <code class="computeroutput"><span class="number">10</span></code>).
289                      This generator never fails (unless the underlying output stream
290                      reports an error).
291                    </p>
292                  </td>
293</tr>
294<tr>
295<td>
296                    <p>
297</p>
298<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">ushort_</span>
299<span class="identifier">uint_</span>
300<span class="identifier">ulong_</span>
301<span class="identifier">ulong_long</span></pre>
302<p>
303                    </p>
304                  </td>
305<td>
306                    <p>
307                      Generate the unsigned integer provided by a mandatory attribute
308                      using the default formatting (radix is <code class="computeroutput"><span class="number">10</span></code>).
309                      This generator never fails (unless the underlying output stream
310                      reports an error).
311                    </p>
312                  </td>
313</tr>
314<tr>
315<td>
316                    <p>
317</p>
318<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">ushort_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
319<span class="identifier">uint_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
320<span class="identifier">ulong_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
321<span class="identifier">ulong_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></pre>
322<p>
323                    </p>
324                  </td>
325<td>
326                    <p>
327                      Generate the unsigned integer provided by the immediate literal
328                      value the generator is initialized from using the default formatting
329                      (radix is <code class="computeroutput"><span class="number">10</span></code>).
330                      If this generator has an associated attribute it succeeds only
331                      if the attribute is equal to the immediate literal (unless
332                      the underlying output stream reports an error). Otherwise this
333                      generator fails and does not generate any output.
334                    </p>
335                  </td>
336</tr>
337<tr>
338<td>
339                    <p>
340</p>
341<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">bin</span>
342<span class="identifier">oct</span>
343<span class="identifier">hex</span></pre>
344<p>
345                    </p>
346                  </td>
347<td>
348                    <p>
349                      Generate the unsigned integer provided by a mandatory attribute
350                      using the default formatting and the corresponding radix (<code class="computeroutput"><span class="identifier">bin</span></code>: radix is <code class="computeroutput"><span class="number">2</span></code>, <code class="computeroutput"><span class="identifier">oct</span></code>:
351                      radix is <code class="computeroutput"><span class="number">8</span></code>, <code class="computeroutput"><span class="identifier">hex</span></code>: radix is <code class="computeroutput"><span class="number">16</span></code>). This generator never fails
352                      (unless the underlying output stream reports an error).
353                    </p>
354                  </td>
355</tr>
356<tr>
357<td>
358                    <p>
359</p>
360<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">bin</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
361<span class="identifier">oct</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
362<span class="identifier">hex</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></pre>
363<p>
364                    </p>
365                  </td>
366<td>
367                    <p>
368                      Generate the unsigned integer provided by the immediate literal
369                      value the generator is initialized from using the default formatting
370                      and the corresponding radix (<code class="computeroutput"><span class="identifier">bin</span></code>:
371                      radix is <code class="computeroutput"><span class="number">2</span></code>, <code class="computeroutput"><span class="identifier">oct</span></code>: radix is <code class="computeroutput"><span class="number">8</span></code>, <code class="computeroutput"><span class="identifier">hex</span></code>:
372                      radix is <code class="computeroutput"><span class="number">16</span></code>). If
373                      this generator has an associated attribute it succeeds only
374                      if the attribute is equal to the immediate literal (unless
375                      the underlying output stream reports an error). Otherwise this
376                      generator fails and does not generate any output.
377                    </p>
378                  </td>
379</tr>
380</tbody>
381</table></div>
382<p>
383            All generators listed in the table above (except <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>) are predefined specializations of the
384            <code class="computeroutput"><span class="identifier">uint_generator</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">&gt;</span></code>
385            basic unsigned integer number generator type described below. It is possible
386            to directly use this type to create unsigned integer generators using
387            a wide range of formatting options.
388          </p>
389<div class="informaltable"><table class="table">
390<colgroup>
391<col>
392<col>
393</colgroup>
394<thead><tr>
395<th>
396                    <p>
397                      Expression
398                    </p>
399                  </th>
400<th>
401                    <p>
402                      Semantics
403                    </p>
404                  </th>
405</tr></thead>
406<tbody>
407<tr>
408<td>
409                    <p>
410</p>
411<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">uint_generator</span><span class="special">&lt;</span>
412    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span>
413<span class="special">&gt;()</span></pre>
414<p>
415                    </p>
416                  </td>
417<td>
418                    <p>
419                      Generate the unsigned integer of type <code class="computeroutput"><span class="identifier">Num</span></code>
420                      provided by a mandatory attribute using the specified <code class="computeroutput"><span class="identifier">Radix</span></code> (allowed values are
421                      from the (inclusive) range from <code class="computeroutput"><span class="number">2</span></code>
422                      .. <code class="computeroutput"><span class="number">36</span></code>, the default
423                      value is <code class="computeroutput"><span class="number">10</span></code>).This
424                      generator never fails (unless the underlying output stream
425                      reports an error).
426                    </p>
427                  </td>
428</tr>
429<tr>
430<td>
431                    <p>
432</p>
433<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">uint_generator</span><span class="special">&lt;</span>
434    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span>
435<span class="special">&gt;()(</span><span class="identifier">num</span><span class="special">)</span></pre>
436<p>
437                    </p>
438                  </td>
439<td>
440                    <p>
441                      Generate the unsigned integer of type <code class="computeroutput"><span class="identifier">Num</span></code>
442                      provided by the immediate literal value the generator is initialized
443                      from, using the specified <code class="computeroutput"><span class="identifier">Radix</span></code>
444                      (allowed values are from the (inclusive) range from <code class="computeroutput"><span class="number">2</span></code> .. <code class="computeroutput"><span class="number">36</span></code>,
445                      the default value is <code class="computeroutput"><span class="number">10</span></code>).
446                      If this generator has an associated attribute it succeeds only
447                      if the attribute is equal to the immediate literal (unless
448                      the underlying output stream reports an error). Otherwise this
449                      generator fails and does not generate any output.
450                    </p>
451                  </td>
452</tr>
453</tbody>
454</table></div>
455<h6>
456<a name="spirit.karma.reference.numeric.unsigned_int.h7"></a>
457            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.additional_requirements"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.additional_requirements">Additional
458            Requirements</a>
459          </h6>
460<p>
461            The following lists enumerate the requirements which must be met in order
462            to use a certain type <code class="computeroutput"><span class="identifier">Num</span></code>
463            to instantiate and use a <code class="computeroutput"><span class="identifier">uint_generator</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">&gt;</span></code>.
464          </p>
465<p>
466            If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_integral</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;::</span><span class="identifier">value</span></code> is <code class="computeroutput"><span class="keyword">true</span></code>
467            the type <code class="computeroutput"><span class="identifier">Num</span></code> must have
468            defined:
469          </p>
470<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
471<li class="listitem">
472                comparison operators for: <code class="computeroutput"><span class="special">&lt;</span></code>,
473                <code class="computeroutput"><span class="special">&lt;=</span></code>, <code class="computeroutput"><span class="special">==</span></code>, <code class="computeroutput"><span class="special">!=</span></code>,
474                <code class="computeroutput"><span class="special">&gt;</span></code>, and <code class="computeroutput"><span class="special">&gt;=</span></code>
475              </li>
476<li class="listitem">
477                numeric operators for: <code class="computeroutput"><span class="special">+</span></code>,
478                <code class="computeroutput"><span class="special">-</span></code>, <code class="computeroutput"><span class="special">/</span></code>,
479                <code class="computeroutput"><span class="special">*</span></code>, and <code class="computeroutput"><span class="special">%</span></code>
480              </li>
481</ul></div>
482<p>
483            If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_integral</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;::</span><span class="identifier">value</span></code> is <code class="computeroutput"><span class="keyword">false</span></code>
484            the type <code class="computeroutput"><span class="identifier">Num</span></code> must have
485            defined:
486          </p>
487<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
488<li class="listitem">
489                comparison operators for: <code class="computeroutput"><span class="special">&lt;</span></code>,
490                <code class="computeroutput"><span class="special">&lt;=</span></code>, <code class="computeroutput"><span class="special">==</span></code>, <code class="computeroutput"><span class="special">!=</span></code>,
491                <code class="computeroutput"><span class="special">&gt;</span></code>, and <code class="computeroutput"><span class="special">&gt;=</span></code>
492              </li>
493<li class="listitem">
494                numeric operators for: <code class="computeroutput"><span class="special">+</span></code>,
495                <code class="computeroutput"><span class="special">-</span></code>, <code class="computeroutput"><span class="special">/</span></code>,
496                <code class="computeroutput"><span class="special">*</span></code>, and <code class="computeroutput"><span class="special">%</span></code>
497              </li>
498<li class="listitem">
499                helper functions implementing the interface and the semantics of:
500                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">fmod</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pow</span></code>,
501                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">lround</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ltrunc</span></code>,
502                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">floor</span></code>, and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ceil</span></code>.
503                These need to be defined in a way so that they will be found using
504                argument dependent lookup (ADL).
505              </li>
506</ul></div>
507<h6>
508<a name="spirit.karma.reference.numeric.unsigned_int.h8"></a>
509            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.attributes"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.attributes">Attributes</a>
510          </h6>
511<div class="informaltable"><table class="table">
512<colgroup>
513<col>
514<col>
515</colgroup>
516<thead><tr>
517<th>
518                    <p>
519                      Expression
520                    </p>
521                  </th>
522<th>
523                    <p>
524                      Attribute
525                    </p>
526                  </th>
527</tr></thead>
528<tbody>
529<tr>
530<td>
531                    <p>
532                      <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
533                    </p>
534                  </td>
535<td>
536                    <p>
537                      <code class="computeroutput"><span class="identifier">unused</span></code>
538                    </p>
539                  </td>
540</tr>
541<tr>
542<td>
543                    <p>
544                      <code class="computeroutput"><span class="identifier">ushort_</span></code>
545                    </p>
546                  </td>
547<td>
548                    <p>
549                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">short</span></code>,
550                      attribute is mandatory (otherwise compilation will fail)
551                    </p>
552                  </td>
553</tr>
554<tr>
555<td>
556                    <p>
557                      <code class="computeroutput"><span class="identifier">ushort_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
558                    </p>
559                  </td>
560<td>
561                    <p>
562                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">short</span></code>,
563                      attribute is optional, if it is supplied, the generator compares
564                      the attribute with <code class="computeroutput"><span class="identifier">num</span></code>
565                      and succeeds only if both are equal, failing otherwise.
566                    </p>
567                  </td>
568</tr>
569<tr>
570<td>
571                    <p>
572                      <code class="computeroutput"><span class="identifier">uint_</span></code>
573                    </p>
574                  </td>
575<td>
576                    <p>
577                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span></code>,
578                      attribute is mandatory (otherwise compilation will fail)
579                    </p>
580                  </td>
581</tr>
582<tr>
583<td>
584                    <p>
585                      <code class="computeroutput"><span class="identifier">uint_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
586                    </p>
587                  </td>
588<td>
589                    <p>
590                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span></code>,
591                      attribute is optional, if it is supplied, the generator compares
592                      the attribute with <code class="computeroutput"><span class="identifier">num</span></code>
593                      and succeeds only if both are equal, failing otherwise.
594                    </p>
595                  </td>
596</tr>
597<tr>
598<td>
599                    <p>
600                      <code class="computeroutput"><span class="identifier">ulong_</span></code>
601                    </p>
602                  </td>
603<td>
604                    <p>
605                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span></code>,
606                      attribute is mandatory (otherwise compilation will fail)
607                    </p>
608                  </td>
609</tr>
610<tr>
611<td>
612                    <p>
613                      <code class="computeroutput"><span class="identifier">ulong_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
614                    </p>
615                  </td>
616<td>
617                    <p>
618                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span></code>,
619                      attribute is optional, if it is supplied, the generator compares
620                      the attribute with <code class="computeroutput"><span class="identifier">num</span></code>
621                      and succeeds only if both are equal, failing otherwise.
622                    </p>
623                  </td>
624</tr>
625<tr>
626<td>
627                    <p>
628                      <code class="computeroutput"><span class="identifier">ulong_long</span></code>
629                    </p>
630                  </td>
631<td>
632                    <p>
633                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span>
634                      <span class="keyword">long</span></code>, attribute is mandatory
635                      (otherwise compilation will fail)
636                    </p>
637                  </td>
638</tr>
639<tr>
640<td>
641                    <p>
642                      <code class="computeroutput"><span class="identifier">ulong_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
643                    </p>
644                  </td>
645<td>
646                    <p>
647                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span>
648                      <span class="keyword">long</span></code>, attribute is optional,
649                      if it is supplied, the generator compares the attribute with
650                      <code class="computeroutput"><span class="identifier">num</span></code> and succeeds
651                      only if both are equal, failing otherwise.
652                    </p>
653                  </td>
654</tr>
655<tr>
656<td>
657                    <p>
658</p>
659<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">bin</span>
660<span class="identifier">oct</span>
661<span class="identifier">hex</span></pre>
662<p>
663                    </p>
664                  </td>
665<td>
666                    <p>
667                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span></code>,
668                      attribute is mandatory (otherwise compilation will fail)
669                    </p>
670                  </td>
671</tr>
672<tr>
673<td>
674                    <p>
675</p>
676<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">bin</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
677<span class="identifier">oct</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
678<span class="identifier">hex</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></pre>
679<p>
680                    </p>
681                  </td>
682<td>
683                    <p>
684                      <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span></code>,
685                      attribute is optional, if it is supplied, the generator compares
686                      the attribute with <code class="computeroutput"><span class="identifier">num</span></code>
687                      and succeeds only if both are equal, failing otherwise.
688                    </p>
689                  </td>
690</tr>
691<tr>
692<td>
693                    <p>
694</p>
695<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">uint_generator</span><span class="special">&lt;</span>
696    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span>
697<span class="special">&gt;()</span></pre>
698<p>
699                    </p>
700                  </td>
701<td>
702                    <p>
703                      <code class="computeroutput"><span class="identifier">Num</span></code>, attribute
704                      is mandatory (otherwise compilation will fail)
705                    </p>
706                  </td>
707</tr>
708<tr>
709<td>
710                    <p>
711</p>
712<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">uint_generator</span><span class="special">&lt;</span>
713    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span>
714<span class="special">&gt;()(</span><span class="identifier">num</span><span class="special">)</span></pre>
715<p>
716                    </p>
717                  </td>
718<td>
719                    <p>
720                      <code class="computeroutput"><span class="identifier">Num</span></code>, attribute
721                      is optional, if it is supplied, the generator compares the
722                      attribute with <code class="computeroutput"><span class="identifier">num</span></code>
723                      and succeeds only if both are equal, failing otherwise.
724                    </p>
725                  </td>
726</tr>
727</tbody>
728</table></div>
729<div class="note"><table border="0" summary="Note">
730<tr>
731<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
732<th align="left">Note</th>
733</tr>
734<tr><td align="left" valign="top"><p>
735              In addition to their usual attribute of type <code class="computeroutput"><span class="identifier">Num</span></code>
736              all listed generators accept an instance of a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;</span></code> as well. If the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> is initialized (holds a value)
737              the generators behave as if their attribute was an instance of <code class="computeroutput"><span class="identifier">Num</span></code> and emit the value stored in
738              the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code>.
739              Otherwise the generators will fail.
740            </p></td></tr>
741</table></div>
742<h6>
743<a name="spirit.karma.reference.numeric.unsigned_int.h9"></a>
744            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.complexity"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.complexity">Complexity</a>
745          </h6>
746<div class="blockquote"><blockquote class="blockquote"><p>
747              O(N), where <code class="computeroutput"><span class="identifier">N</span></code> is the
748              number of digits needed to represent the generated integer number
749            </p></blockquote></div>
750<h6>
751<a name="spirit.karma.reference.numeric.unsigned_int.h10"></a>
752            <span class="phrase"><a name="spirit.karma.reference.numeric.unsigned_int.example"></a></span><a class="link" href="unsigned_int.html#spirit.karma.reference.numeric.unsigned_int.example">Example</a>
753          </h6>
754<div class="note"><table border="0" summary="Note">
755<tr>
756<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
757<th align="left">Note</th>
758</tr>
759<tr><td align="left" valign="top"><p>
760              The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.karma.reference.basics.examples">Basics Examples</a>
761              section.
762            </p></td></tr>
763</table></div>
764<p>
765            Some includes:
766          </p>
767<p>
768</p>
769<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
770<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">support_utree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
771<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
772<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
773<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">std_pair</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
774<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
775<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span>
776</pre>
777<p>
778          </p>
779<p>
780            Some using declarations:
781          </p>
782<p>
783</p>
784<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">uint_</span><span class="special">;</span>
785<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">lit</span><span class="special">;</span>
786</pre>
787<p>
788          </p>
789<p>
790            Basic usage of an <code class="computeroutput"><span class="identifier">uint</span></code>
791            generator:
792          </p>
793<p>
794</p>
795<pre class="programlisting"><span class="identifier">test_generator</span><span class="special">(</span><span class="string">"2"</span><span class="special">,</span> <span class="identifier">lit</span><span class="special">(</span><span class="number">2U</span><span class="special">));</span>
796<span class="identifier">test_generator</span><span class="special">(</span><span class="string">"2"</span><span class="special">,</span> <span class="identifier">uint_</span><span class="special">(</span><span class="number">2</span><span class="special">));</span>
797<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"2"</span><span class="special">,</span> <span class="identifier">uint_</span><span class="special">(</span><span class="number">2</span><span class="special">),</span> <span class="number">2</span><span class="special">);</span>
798<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">""</span><span class="special">,</span> <span class="identifier">uint_</span><span class="special">(</span><span class="number">2</span><span class="special">),</span> <span class="number">3</span><span class="special">);</span>    <span class="comment">// fails (as 2 != 3)!</span>
799<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"2"</span><span class="special">,</span> <span class="identifier">uint_</span><span class="special">,</span> <span class="number">2</span><span class="special">);</span>
800</pre>
801<p>
802          </p>
803</div>
804<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
805<td align="left"></td>
806<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
807        Distributed under the Boost Software License, Version 1.0. (See accompanying
808        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>)
809      </p>
810</div></td>
811</tr></table>
812<hr>
813<div class="spirit-nav">
814<a accesskey="p" href="../numeric.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.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="signed_int.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
815</div>
816</body>
817</html>
818