2002-09-16 19:25:33 +00:00
<!doctype html public "-//ietf//dtd html//en">
2003-03-12 13:29:12 +00:00
< html >< head >< title > boost::mpl::plus</ title >
2002-09-16 19:25:33 +00:00
< link rel = "stylesheet" href = "../mpl_wiki.css" >
</ head >< body bgcolor = "white" >
2003-03-12 13:29:12 +00:00
< h1 >< a href = "../Table_of_Contents.html" >< img src = "../mpl_logo.jpg" alt = "[Home]" border = 0 align = "right" ></ a > plus</ h1 >< h3 > Synopsis</ h3 >
2002-09-16 19:25:33 +00:00
< p >
< pre >
template<
typename T1
2003-03-12 13:29:12 +00:00
, typename T2
, typename T3 = integral_c< int,0>
2002-09-16 19:25:33 +00:00
, ...
2003-03-12 13:29:12 +00:00
, typename Tn = integral_c< int,0>
2002-09-16 19:25:33 +00:00
>
struct plus
{
typedef < em > unspecified</ em > type;
};
</ pre >
< p >
< h3 > Description</ h3 >
< p >
Returns the sum of its arguments [< a href = "#1" > 1</ a > ].
< p >
< h3 > Definition</ h3 >
< p >
< pre >
2003-03-12 13:29:12 +00:00
#include "< a href = "../../../../../boost/mpl/plus.hpp" > boost/mpl/plus.hpp</ a > "
2002-09-16 19:25:33 +00:00
</ pre >
< p >
< h3 > Parameters</ h3 >
< table border = "1" >
< tr >< th > Parameter </ th >< th > Requirement </ th >< th > Description </ th ></ tr >
< tr >< td >< code > T1, T2, .., Tn</ code ></ td >< td > A model of < a href = "../Integral_Constant.html" > Integral Constant</ a ></ td >< td ></ td ></ tr >
</ table >
< p >
< h3 > Expression semantics</ h3 >
< p >
< table border = "1" >
< tr >< th > Expression </ th >< th > Expression type </ th >< th > Precondition </ th >< th > Semantics </ th >< th > Postcondition </ th ></ tr >
< tr >< td >< code > typedef plus< t1,t2,..,tn> ::type sum;</ code ></ td >< td > A model of < a href = "../Integral_Constant.html" > Integral Constant</ a ></ td >< td ></ td >< td > Equivalent to < code > typedef integral_c< typeof(t1::value + t2::value .. + tn::value), t1::value + t2::value .. + tn::value > sum;</ code ></ td >< td ></ td ></ tr >
</ table >
< p >
< h3 > Complexity</ h3 >
< p >
Amortized constant time.
< p >
< h3 > Example</ h3 >
< p >
< pre >
typedef plus< integral_c< short,-1> , integral_c< long,10> > ::type sum;
BOOST_STATIC_ASSERT(sum::value == 9));
BOOST_MPL_ASSERT_IS_SAME(sum::value_type, long);
</ pre >
< p >
< h3 > Notes</ h3 >
< p >
[< a name = "1" > 1</ a > ] The < code > plus</ code > metafunction can be (and is expected to be) specialized by user to work on user-defined types that do not satisfy the < a href = "../Integral_Constant.html" > Integral Constant</ a > requirements. The requirements listed here are the ones imposed by the default implementation.< br >
< p >
< h3 > See also</ h3 >
< p >
< a href = "../Metafunctions.html" > Metafunctions</ a > , < code >< a href = "../Reference/minus.html" > minus</ a ></ code > , < code >< a href = "../Reference/multiplies.html" > multiplies</ a ></ code > , < code >< a href = "../Reference/divides.html" > divides</ a ></ code > , < code >< a href = "../Reference/modulus.html" > modulus</ a ></ code > , < code >< a href = "../Reference/negate.html" > negate</ a ></ code >
< p >< hr >
2003-03-12 13:29:12 +00:00
< a href = "../Table_of_Contents.html" > Table of Contents</ a >< br > Last edited March 10, 2003 6:30 am</ body ></ html >