modulus
template<
typename T1
, typaname T2
>
struct modulus
{
typedef unspecified type;
};
Returns the modulus of its arguments [1].
#include "boost/mpl/arithmetic/modulus.hpp"
| Parameter | Requirement | Description |
|---|---|---|
T1, T2 | A model of Integral Constant |
| 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; |
Amortized constant time.
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);
[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.
Metafunctions, divides, multiplies, plus, minus, negate