...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 , typename T3 = integral_c<int,0> , ... , typename Tn = integral_c<int,0> > struct plus { typedefunspecifiedtype; };

Returns the sum of its arguments [1].

#include "boost/mpl/plus.hpp"

Parameter | Requirement | Description |
---|---|---|

`T1, T2, .., Tn` | A model of Integral Constant |

Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|

`typedef plus<t1,t2,..,tn>::type sum;` | A model of Integral Constant | Equivalent to `typedef integral_c<typeof(t1::value + t2::value .. + tn::value), t1::value + t2::value .. + tn::value > sum;` |

Amortized constant time.

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);

[1] The `plus`

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, `minus`

, `multiplies`

, `divides`

, `modulus`

, `negate`

Table of Contents

Last edited March 10, 2003 6:30 am