| 1 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 4 | <!-- Copyright Aleksey Gurtovoy 2006. Distributed under the Boost --> |
|---|
| 5 | <!-- Software License, Version 1.0. (See accompanying --> |
|---|
| 6 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> |
|---|
| 7 | <head> |
|---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 9 | <meta name="generator" content="Docutils 0.3.6: http://docutils.sourceforge.net/" /> |
|---|
| 10 | <title>The MPL Reference Manual: plus</title> |
|---|
| 11 | <link rel="stylesheet" href="../style.css" type="text/css" /> |
|---|
| 12 | </head> |
|---|
| 13 | <body class="docframe refmanual"> |
|---|
| 14 | <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Prev</a> <a href="./minus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group">Back <a href="./minus.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 15 | <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./arithmetic-operations.html" class="navigation-link">Arithmetic Operations</a> / <a href="./plus.html" class="navigation-link">plus</a></td> |
|---|
| 16 | </tr></table><div class="header-separator"></div> |
|---|
| 17 | <div class="section" id="plus"> |
|---|
| 18 | <h1><a class="toc-backref" href="./arithmetic-operations.html#id462" name="plus">plus</a></h1> |
|---|
| 19 | <div class="section" id="plus-synopsis"> |
|---|
| 20 | <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> |
|---|
| 21 | <pre class="literal-block"> |
|---|
| 22 | template< |
|---|
| 23 | typename T1 |
|---|
| 24 | , typename T2 |
|---|
| 25 | , typename T3 = <em>unspecified</em> |
|---|
| 26 | <em>...</em> |
|---|
| 27 | , typename T<em>n</em> = <em>unspecified</em> |
|---|
| 28 | > |
|---|
| 29 | struct <a href="./plus.html" class="identifier">plus</a> |
|---|
| 30 | { |
|---|
| 31 | typedef <em>unspecified</em> type; |
|---|
| 32 | }; |
|---|
| 33 | </pre> |
|---|
| 34 | </div> |
|---|
| 35 | <div class="section" id="plus-description"> |
|---|
| 36 | <h3><a class="subsection-title" href="#description" name="description">Description</a></h3> |
|---|
| 37 | <p>Returns the sum of its arguments.</p> |
|---|
| 38 | </div> |
|---|
| 39 | <div class="section" id="plus-header"> |
|---|
| 40 | <h3><a class="subsection-title" href="#header" name="header">Header</a></h3> |
|---|
| 41 | <pre class="literal-block"> |
|---|
| 42 | #include <<a href="../../../../boost/mpl/plus.hpp" class="header">boost/mpl/plus.hpp</a>> |
|---|
| 43 | #include <<a href="../../../../boost/mpl/arithmetic.hpp" class="header">boost/mpl/arithmetic.hpp</a>> |
|---|
| 44 | </pre> |
|---|
| 45 | </div> |
|---|
| 46 | <div class="section" id="plus-model-of"> |
|---|
| 47 | <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3> |
|---|
| 48 | <p><a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a></p> |
|---|
| 49 | </div> |
|---|
| 50 | <div class="section" id="plus-parameters"> |
|---|
| 51 | <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> |
|---|
| 52 | <table border="1" class="table"> |
|---|
| 53 | <colgroup> |
|---|
| 54 | <col width="17%" /> |
|---|
| 55 | <col width="30%" /> |
|---|
| 56 | <col width="53%" /> |
|---|
| 57 | </colgroup> |
|---|
| 58 | <thead valign="bottom"> |
|---|
| 59 | <tr><th>Parameter</th> |
|---|
| 60 | <th>Requirement</th> |
|---|
| 61 | <th>Description</th> |
|---|
| 62 | </tr> |
|---|
| 63 | </thead> |
|---|
| 64 | <tbody valign="top"> |
|---|
| 65 | <tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td> |
|---|
| 66 | <td><a class="reference" href="./integral-constant.html">Integral Constant</a></td> |
|---|
| 67 | <td>Operation's arguments.</td> |
|---|
| 68 | </tr> |
|---|
| 69 | </tbody> |
|---|
| 70 | </table> |
|---|
| 71 | <p>[<em>Note:</em> The requirements listed in this specification |
|---|
| 72 | are the ones imposed by the default implementation. See <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a> concept |
|---|
| 73 | for the details on how to provide an implementation for a user-defined numeric type |
|---|
| 74 | that does not satisfy the <a class="reference" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p> |
|---|
| 75 | </div> |
|---|
| 76 | <div class="section" id="plus-expression-semantics"> |
|---|
| 77 | <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> |
|---|
| 78 | <p>For any <a class="reference" href="./integral-constant.html">Integral Constant</a>s <em>c</em><sub>1</sub>,<em>c</em><sub>2</sub>,... <em>c</em><sub>n</sub>:</p> |
|---|
| 79 | <pre class="literal-block"> |
|---|
| 80 | typedef <a href="./plus.html" class="identifier">plus</a><c1,<em>...</em>c<em>n</em>>::type r; |
|---|
| 81 | </pre> |
|---|
| 82 | <table class="field-list" frame="void" rules="none"> |
|---|
| 83 | <col class="field-name" /> |
|---|
| 84 | <col class="field-body" /> |
|---|
| 85 | <tbody valign="top"> |
|---|
| 86 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td> |
|---|
| 87 | </tr> |
|---|
| 88 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 89 | <pre class="last literal-block"> |
|---|
| 90 | typedef <a href="./integral-c.html" class="identifier">integral_c</a>< |
|---|
| 91 | typeof(c1::value + c2::value) |
|---|
| 92 | , ( c1::value + c2::value ) |
|---|
| 93 | > c; |
|---|
| 94 | |
|---|
| 95 | typedef <a href="./plus.html" class="identifier">plus</a><c,c3,<em>...</em>c<em>n</em>>::type r; |
|---|
| 96 | </pre> |
|---|
| 97 | </td> |
|---|
| 98 | </tr> |
|---|
| 99 | </tbody> |
|---|
| 100 | </table> |
|---|
| 101 | <!-- .......................................................................... --> |
|---|
| 102 | <pre class="literal-block"> |
|---|
| 103 | typedef <a href="./plus.html" class="identifier">plus</a><c1,<em>...</em>c<em>n</em>> r; |
|---|
| 104 | </pre> |
|---|
| 105 | <table class="field-list" frame="void" rules="none"> |
|---|
| 106 | <col class="field-name" /> |
|---|
| 107 | <col class="field-body" /> |
|---|
| 108 | <tbody valign="top"> |
|---|
| 109 | <tr class="field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference" href="./integral-constant.html">Integral Constant</a>.</td> |
|---|
| 110 | </tr> |
|---|
| 111 | <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> |
|---|
| 112 | <pre class="last literal-block"> |
|---|
| 113 | struct r : <a href="./plus.html" class="identifier">plus</a><c1,<em>...</em>c<em>n</em>>::type {}; |
|---|
| 114 | </pre> |
|---|
| 115 | </td> |
|---|
| 116 | </tr> |
|---|
| 117 | </tbody> |
|---|
| 118 | </table> |
|---|
| 119 | </div> |
|---|
| 120 | <div class="section" id="plus-complexity"> |
|---|
| 121 | <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> |
|---|
| 122 | <p>Amortized constant time.</p> |
|---|
| 123 | </div> |
|---|
| 124 | <div class="section" id="plus-example"> |
|---|
| 125 | <h3><a class="subsection-title" href="#example" name="example">Example</a></h3> |
|---|
| 126 | <pre class="literal-block"> |
|---|
| 127 | typedef <a href="./plus.html" class="identifier">plus</a>< <a href="./int.html" class="identifier">int_</a><-10>, <a href="./int.html" class="identifier">int_</a><3>, <a href="./long.html" class="identifier">long_</a><1> >::type r; |
|---|
| 128 | <a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( r::value, ==, -6 ); |
|---|
| 129 | <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< r::<a href="./value-type.html" class="identifier">value_type</a>, long > )); |
|---|
| 130 | </pre> |
|---|
| 131 | </div> |
|---|
| 132 | <div class="section" id="plus-see-also"> |
|---|
| 133 | <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> |
|---|
| 134 | <p><a class="reference" href="./arithmetic-operations.html">Arithmetic Operations</a>, <a class="reference" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="refentry reference" href="./numeric-cast.html"><tt class="refentry literal"><span class="pre">numeric_cast</span></tt></a>, <a class="refentry reference" href="./minus.html"><tt class="refentry literal"><span class="pre">minus</span></tt></a>, <a class="refentry reference" href="./negate.html"><tt class="refentry literal"><span class="pre">negate</span></tt></a>, <a class="refentry reference" href="./times.html"><tt class="refentry literal"><span class="pre">times</span></tt></a></p> |
|---|
| 135 | <!-- modtime: November 10, 2004 04:34:12 +0000 --> |
|---|
| 136 | <!-- Metafunctions/Arithmetic Operations//minus |20 --> |
|---|
| 137 | </div> |
|---|
| 138 | </div> |
|---|
| 139 | |
|---|
| 140 | <div class="footer-separator"></div> |
|---|
| 141 | <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Prev</a> <a href="./minus.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group">Back <a href="./minus.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./arithmetic-operations.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> |
|---|
| 142 | </tr></table></body> |
|---|
| 143 | </html> |
|---|