boost::mpl::modulus

# modulus

### Synopsis

    template<
          typename T1
        , typename T2
        >
    struct modulus
    {
        typedef unspecified type;
    };

### Description

Returns the modulus of its arguments [1].

### Definition

    #include "boost/mpl/modulus.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`T1, T2` | A model of Integral Constant |

### Expression semantics

Expression | Expression type | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typedef modulus<t1,t2>::type mod;` | A model of Integral Constant | `t2::value != 0` | Equivalent to `typedef integral_c<typeof(t1::value % t2::value), t1::value % t2::value> mod;` |

### Complexity

Amortized constant time.

### Example

    typedef modulus< integral_c<short,10>, integral_c<long,3> >::type mod;
    BOOST_STATIC_ASSERT(mod::value == 1));
    BOOST_MPL_ASSERT_IS_SAME(mod::value_type, long);

### Notes

[1] The `modulus` metafunction can be (and is expected to be) specialized by user to work on user-defined types that do not satisfy the Integral Constant requirements. The requirements listed here are the ones imposed by the default implementation.

### See also

Metafunctions, `divides`, `multiplies`, `plus`, `minus`, `negate`

Table of Contents
Last edited March 10, 2003 6:32 am