...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

template< typename T1 , typename T2 > struct modulus { typedefunspecifiedtype; };

Returns the modulus of its arguments [1].

#include "boost/mpl/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`

Table of Contents

Last edited March 10, 2003 6:32 am