• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Metafunctions/Arithmetic Operations//times |30
2
3times
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 times
19    {
20        typedef |unspecified| type;
21    };
22
23
24
25Description
26-----------
27
28Returns the product of its arguments.
29
30
31Header
32------
33
34.. parsed-literal::
35
36    #include <boost/mpl/times.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 times<c1,\ |...|\ c\ *n*\>::type r;
67
68:Return type:
69    |Integral Constant|.
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            > c;
80
81        typedef times<c,c3,\ |...|\c\ *n*\>::type r;
82
83.. ..........................................................................
84
85
86.. parsed-literal::
87
88    typedef times<c1,\ |...|\ c\ *n*\> r;
89
90:Return type:
91    |Integral Constant|.
92
93:Semantics:
94    Equivalent to
95
96    .. parsed-literal::
97
98        struct r : times<c1,\ |...|\ c\ *n*\>::type {};
99
100
101Complexity
102----------
103
104Amortized constant time.
105
106
107Example
108-------
109
110.. parsed-literal::
111
112    typedef times< int_<-10>, int_<3>, long_<1> >::type r;
113    BOOST_MPL_ASSERT_RELATION( r::value, ==, -30 );
114    BOOST_MPL_ASSERT(( is_same< r::value_type, long > ));
115
116
117See also
118--------
119
120|Metafunctions|, |Numeric Metafunction|, |numeric_cast|, |divides|, |modulus|, |plus|
121
122
123.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
124   Distributed under the Boost Software License, Version 1.0. (See accompanying
125   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
126