The arithmetic, comparison and bitwise metafunctions are polymorphic, and can operate on a variety of numeric types, including rational, fixed-point and complex numbers. The metafunctions allow mixed arithmetic, meaning that you can perform an operation on the arguments of different types, and the result will yeild the largest/most general of the arguments types. The infrastructure is provided to allow easy plugging of user-defined numeric types which can be made freely intermixable 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.
If you were using MPL numeric metafunctions on your own integral wrapper class similar to mpl::int_, you can plug it into the new infrustructure by extending the class 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_iny type;
};
|
template< int n > struct my_int
{
typedef mpl::integral_c_tag tag;
static int const value = n;
typedef my_iny type;
};
|