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