C++的一个好库。。。现在很流行
源代码在线查看: plus.rst
软件大小: |
21075 K |
上传用户: |
lyyfengyutongzh |
|
|
关键词: |
|
下载地址: |
免注册下载 普通下载
|
|
.. Metafunctions/Arithmetic Operations//plus |10
plus
====
Synopsis
--------
.. parsed-literal::
template<
typename T1
, typename T2
, typename T3 = |unspecified|
|...|
, typename T\ *n* = |unspecified|
>
struct plus
{
typedef |unspecified| type;
};
Description
-----------
Returns the sum of its arguments.
Header
------
.. parsed-literal::
#include
#include
Model of
--------
|Numeric Metafunction|
Parameters
----------
+---------------+---------------------------+-----------------------------------------------+
| Parameter | Requirement | Description |
+===============+===========================+===============================================+
| |T1...Tn| | |Integral Constant| | Operation's arguments. |
+---------------+---------------------------+-----------------------------------------------+
|Note:| |numeric metafunction note| |-- end note|
Expression semantics
--------------------
For any |Integral Constant|\ s |c1...cn|:
.. parsed-literal::
typedef plus::type r;
:Return type:
|Integral Constant|.
:Semantics:
Equivalent to
.. parsed-literal::
typedef integral_c<
typeof(c1::value + c2::value)
, ( c1::value + c2::value )
> c;
typedef plus::type r;
.. ..........................................................................
.. parsed-literal::
typedef plus r;
:Return type:
|Integral Constant|.
:Semantics:
Equivalent to
.. parsed-literal::
struct r : plus::type {};
Complexity
----------
Amortized constant time.
Example
-------
.. parsed-literal::
typedef plus< int_, int_, long_ >::type r;
BOOST_MPL_ASSERT_RELATION( r::value, ==, -6 );
BOOST_MPL_ASSERT(( is_same< r::value_type, long > ));
See also
--------
|Arithmetic Operations|, |Numeric Metafunction|, |numeric_cast|, |minus|, |negate|, |times|