Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2005-10-31 16:46:20


--- Andy Little wrote:
> BTW, I have found that the ability to convert a
> rational to an integral_constant if possible is a
> useful utility too, though I'm not quite sure
> what purists would make of it as the resulting
> ::type may be an integral_constant or maybe a
> rational constant. I currently call it
> "simplify_rational_or_numeric". The resulting
::type
> works ok if accessed using the numerator and
> denominator functions, and this allows me to make
> lists of dimensions using both integral_constants
and
> rationals. Maybe there is room for such a concept
as
> an "mpl rational or numeric concept"?

In my yet-to-be-submitted documentation, I have the
following numeric metatype hierarchy:

Numeric Constant
|
+--Real Numeric Constant
| |
| +--Discrete Constant--Bitwise Constant
| | | |
| | +--Integral Constant------+
| | | |
| | +--Big Integral Constant--+
| |
| +--Continuous Constant
| |
| +--Rational Constant
| |
| +--Mixed Numeric Constant
|
+--Complex Numeric Constant

Each concept is defined in terms of the metafunctions
that can operate on it, and their semantics. In this
scheme, both Integral Constants and Rational Constants
are Real Numeric Constants. Not only do the
arithmetic metafunctions (negate, plus, minus, times,
divides), a few comparison metafunctions (equal_to,
not_equal_to), and a few numeric metafunctions
(is_zero, zero, real_part, imaginary_part) work on
them as they do on other Numeric Constants; but all
the other comparison metafunctions (less, greater,
less_equal, greater_equal) and all the other numeric
metafunctions (is_negative, abs, numerator,
denominator, whole_part, fractional_part) work on them
as well. A few metafunctions have different semantics
for Discrete Constants; e.g. the numerator or
whole_part of an Integral Constant is itself, its
denominator is always one, and its fractional_part is
always zero.

To obtain the corresponding run-time values, use the
runtime_value facility, which is required to operate
on all Numeric Constants.

Let me know of any details that need to be fleshed out
for you.

                              Cromwell D. Enage

                
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk