|  | Home | Libraries | People | FAQ | More | 
            The uint_generator class
            is the simplest among the members of the numerics package. The uint_generator can generate unsigned
            integers of arbitrary length and size. The uint_generator
            generator can be used to generate ordinary primitive C/C++ integers or
            even user defined scalars such as bigints (unlimited precision integers)
            if the type follows certain expression requirements (for more information
            about the requirements, see below)).
            The uint_generator is
            a template class. Template parameters fine tune its behavior.
          
// forwards to <boost/spirit/home/karma/numeric/uint.hpp> #include <boost/spirit/include/karma_uint.hpp>
Also, see Include Structure.
| Name | 
|---|
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| 
                       | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
              The generators  | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
               | 
template < typename Num , unsigned Radix> struct uint_generator;
| Parameter | Description | Default | 
|---|---|---|
| 
                       | The numeric base type of the numeric generator. | 
                       | 
| 
                       | 
                      The radix base. This can be any value in the (inclusive) range
                      from  | 
                       | 
Notation
num
                  Numeric literal, any unsigned integer value, or a Lazy
                  Argument that evaluates to an unsigned integer value of
                  type Num
                
Num
                  Type of num: any
                  unsigned integer type, or in case of a Lazy
                  Argument, its return value
                
Radix
                  An integer literal specifying the required radix for the output
                  conversion. Valid values are from the (inclusive) range 2 .. 36.
                
            Semantics of an expression is defined only where it differs from, or
            is not defined in PrimitiveGenerator.
          
| Expression | Semantics | 
|---|---|
| 
                       | 
                      Generate the unsigned integer literal  | 
| 
 ushort_ uint_ ulong_ ulong_long 
 | 
                      Generate the unsigned integer provided by a mandatory attribute
                      using the default formatting (radix is  | 
| 
 ushort_(num) uint_(num) ulong_(num) ulong_long(num) 
 | 
                      Generate the unsigned integer provided by the immediate literal
                      value the generator is initialized from using the default formatting
                      (radix is  | 
| 
 bin oct hex 
 | 
                      Generate the unsigned integer provided by a mandatory attribute
                      using the default formatting and the corresponding radix ( | 
| 
 bin(num) oct(num) hex(num) 
 | 
                      Generate the unsigned integer provided by the immediate literal
                      value the generator is initialized from using the default formatting
                      and the corresponding radix ( | 
            All generators listed in the table above (except lit(num)) are predefined specializations of the
            uint_generator<Num, Radix>
            basic unsigned integer number generator type described below. It is possible
            to directly use this type to create unsigned integer generators using
            a wide range of formatting options.
          
| Expression | Semantics | 
|---|---|
| 
 uint_generator< Num, Radix >() 
 | 
                      Generate the unsigned integer of type  | 
| 
 uint_generator< Num, Radix >()(num) 
 | 
                      Generate the unsigned integer of type  | 
            The following lists enumerate the requirements which must be met in order
            to use a certain type Num
            to instantiate and use a uint_generator<Num, Radix>.
          
            If boost::is_integral<Num>::value is true
            the type Num must have
            defined:
          
<,
                <=, ==, !=,
                >, and >=
              +,
                -, /,
                *, and %
              
            If boost::is_integral<Num>::value is false
            the type Num must have
            defined:
          
<,
                <=, ==, !=,
                >, and >=
              +,
                -, /,
                *, and %
              std::fmod, std::pow,
                std::lround, std::ltrunc,
                std::floor, and std::ceil.
                These need to be defined in a way so that they will be found using
                argument dependent lookup (ADL).
              | Expression | Attribute | 
|---|---|
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
                       | 
                       | 
| 
 bin oct hex 
 | 
                       | 
| 
 bin(num) oct(num) hex(num) 
 | 
                       | 
| 
 uint_generator< Num, Radix >() 
 | 
                       | 
| 
 uint_generator< Num, Radix >()(num) 
 | 
                       | 
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| 
              In addition to their usual attribute of type  | 
O(N), where
Nis the number of digits needed to represent the generated integer number
| ![[Note]](../../../../images/note.png) | Note | 
|---|---|
| The test harness for the example(s) below is presented in the Basics Examples section. | 
Some includes:
#include <boost/spirit/include/karma.hpp> #include <boost/spirit/include/support_utree.hpp> #include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/proto/deep_copy.hpp> #include <iostream> #include <string>
Some using declarations:
using boost::spirit::karma::uint_; using boost::spirit::karma::lit;
            Basic usage of an uint
            generator:
          
test_generator("2", lit(2U)); test_generator("2", uint_(2)); test_generator_attr("2", uint_(2), 2); test_generator_attr("", uint_(2), 3); // fails (as 2 != 3)! test_generator_attr("2", uint_, 2);