1.. Metafunctions/Arithmetic Operations//modulus |50 2 3modulus 4======= 5 6Synopsis 7-------- 8 9.. parsed-literal:: 10 11 template< 12 typename T1 13 , typename T2 14 > 15 struct modulus 16 { 17 typedef |unspecified| type; 18 }; 19 20 21 22Description 23----------- 24 25Returns the modulus of its arguments. 26 27 28Header 29------ 30 31.. parsed-literal:: 32 33 #include <boost/mpl/modulus.hpp> 34 #include <boost/mpl/arithmetic.hpp> 35 36 37Model of 38-------- 39 40|Numeric Metafunction| 41 42 43Parameters 44---------- 45 46+---------------+---------------------------+-----------------------------------------------+ 47| Parameter | Requirement | Description | 48+===============+===========================+===============================================+ 49| ``T1``, ``T2``| |Integral Constant| | Operation's arguments. | 50+---------------+---------------------------+-----------------------------------------------+ 51 52|Note:| |numeric metafunction note| |-- end note| 53 54 55Expression semantics 56-------------------- 57 58For any |Integral Constant|\ s ``c1`` and ``c2``: 59 60 61.. parsed-literal:: 62 63 typedef modulus<c1,c2>::type r; 64 65:Return type: 66 |Integral Constant|. 67 68:Precondition: 69 ``c2::value != 0`` 70 71:Semantics: 72 Equivalent to 73 74 .. parsed-literal:: 75 76 typedef integral_c< 77 typeof(c1::value % c2::value) 78 , ( c1::value % c2::value ) 79 > r; 80 81 82.. .......................................................................... 83 84.. parsed-literal:: 85 86 typedef modulus<c1,c2> r; 87 88:Return type: 89 |Integral Constant|. 90 91:Precondition: 92 ``c2::value != 0`` 93 94:Semantics: 95 Equivalent to 96 97 .. parsed-literal:: 98 99 struct r : modulus<c1,c2>::type {}; 100 101 102Complexity 103---------- 104 105Amortized constant time. 106 107 108Example 109------- 110 111.. parsed-literal:: 112 113 typedef modulus< int_<10>, long_<3> >::type r; 114 BOOST_MPL_ASSERT_RELATION( r::value, ==, 1 ); 115 BOOST_MPL_ASSERT(( is_same< r::value_type, long > )); 116 117 118 119See also 120-------- 121 122|Metafunctions|, |Numeric Metafunction|, |numeric_cast|, |divides|, |times|, |plus| 123 124 125.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 126 Distributed under the Boost Software License, Version 1.0. (See accompanying 127 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 128