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.

The generators ulong_long
and ulong_long(num)
are only available on platforms where the preprocessor constant BOOST_HAS_LONG_LONG is defined (i.e.
on platforms having native support for unsignedlonglong
(64 bit) unsigned integer types).

Note

lit is reused by the
String Generators,
the Character Generators,
and the Numeric Generators. In general, a char generator is created
when you pass in a character, a string generator is created when you
pass in a string, and a numeric generator is created when you use a
numeric literal.

Semantics of an expression is defined only where it differs from, or
is not defined in PrimitiveGenerator.

Expression

Semantics

lit(num)

Generate the unsigned integer literal num
using the default formatting (radix is 10).
This generator never fails (unless the underlying output stream
reports an error).

ushort_uint_ulong_ulong_long

Generate the unsigned integer provided by a mandatory attribute
using the default formatting (radix is 10).
This generator never fails (unless the underlying output stream
reports an error).

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 10).
If this generator has an associated attribute it succeeds only
if the attribute is equal to the immediate literal (unless
the underlying output stream reports an error). Otherwise this
generator fails and does not generate any output.

binocthex

Generate the unsigned integer provided by a mandatory attribute
using the default formatting and the corresponding radix (bin: radix is 2, oct:
radix is 8, hex: radix is 16). This generator never fails
(unless the underlying output stream reports an error).

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 (bin:
radix is 2, oct: radix is 8, hex:
radix is 16). If
this generator has an associated attribute it succeeds only
if the attribute is equal to the immediate literal (unless
the underlying output stream reports an error). Otherwise this
generator fails and does not generate any output.

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 Num
provided by a mandatory attribute using the specified Radix (allowed values are
from the (inclusive) range from 2
.. 36, the default
value is 10).This
generator never fails (unless the underlying output stream
reports an error).

uint_generator<Num,Radix>()(num)

Generate the unsigned integer of type Num
provided by the immediate literal value the generator is initialized
from, using the specified Radix
(allowed values are from the (inclusive) range from 2 .. 36,
the default value is 10).
If this generator has an associated attribute it succeeds only
if the attribute is equal to the immediate literal (unless
the underlying output stream reports an error). Otherwise this
generator fails and does not generate any output.

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:

comparison operators for: <,
<=, ==, !=,
>, and >=

numeric operators for: +,
-, /,
*, and %

If boost::is_integral<Num>::value is false
the type Num must have
defined:

comparison operators for: <,
<=, ==, !=,
>, and >=

numeric operators for: +,
-, /,
*, and %

helper functions implementing the interface and the semantics of:
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).

unsignedlonglong, attribute is optional,
if it is supplied, the generator compares the attribute with
num and succeeds
only if both are equal, failing otherwise.

binocthex

unsignedint,
attribute is mandatory (otherwise compilation will fail)

bin(num)oct(num)hex(num)

unsignedint,
attribute is optional, if it is supplied, the generator compares
the attribute with num
and succeeds only if both are equal, failing otherwise.

uint_generator<Num,Radix>()

Num, attribute
is mandatory (otherwise compilation will fail)

uint_generator<Num,Radix>()(num)

Num, attribute
is optional, if it is supplied, the generator compares the
attribute with num
and succeeds only if both are equal, failing otherwise.

Note

In addition to their usual attribute of type Num
all listed generators accept an instance of a boost::optional<Num> as well. If the boost::optional<> is initialized (holds a value)
the generators behave as if their attribute was an instance of Num and emit the value stored in
the boost::optional<>.
Otherwise the generators will fail.