Front Page / Changelog & History / Changes in Boost 1.32.0 Release / Numeric Metafunction Protocol/Infrastructure

Numeric Metafunction Protocol/Infrastructure

The arithmetic, comparison and bitwise metafunctions are now polymorphic, and can operate on a variety of numeric types, including rational, fixed-point and complex numbers. They allow mixed arithmetic, meaning that you can perform an operation on arguments of different types, and the result will yeild the largest/most general of the argument types. The infrastructure allows user-defined numeric types to be freely intermixed with predefined library types. See http://cvs.sourceforge.net/viewcvs.py/boost/boost/libs/mpl/test/numeric_ops.cpp?view=markup for an illustrative example, and the reference manual for the formal infrastructure specification.

If you were using MPL numeric metafunctions on your own integral wrapper class similar to mpl::int_, you can plug your class into the new infrustructure by extending it with the following member:

typedef mpl::integral_c_tag tag;

For example:

Before Now
template< int n > struct my_int
{
    static int const value = n;
    typedef my_int type;
};
template< int n > struct my_int
{
    typedef mpl::integral_c_tag tag;
    static int const value = n;
    typedef my_int type;
};