arg.html 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
  7. <title>The MPL Reference Manual: arg</title>
  8. <link rel="stylesheet" href="../style.css" type="text/css" />
  9. </head>
  10. <body class="docframe refmanual">
  11. <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./quote.html" class="navigation-link">Prev</a>&nbsp;<a href="./protect.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./quote.html" class="navigation-link">Back</a>&nbsp;<a href="./protect.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument-binding.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  12. <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="./composition-and-argument-binding.html" class="navigation-link">Composition and Argument Binding</a> / <a href="./arg.html" class="navigation-link">arg</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="arg">
  15. <h1><a class="toc-backref" href="./composition-and-argument-binding.html#id1533">arg</a></h1>
  16. <div class="section" id="id946">
  17. <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
  18. <pre class="literal-block">
  19. template&lt; int n &gt; struct <a href="./arg.html" class="identifier">arg</a>;
  20. template&lt;&gt; struct <a href="./arg.html" class="identifier">arg</a>&lt;1&gt;
  21. {
  22. template&lt; typename A1,<em>...</em> typename A<em>n</em> = <em>unspecified</em> &gt;
  23. struct <a href="./apply.html" class="identifier">apply</a>
  24. {
  25. typedef A1 type;
  26. };
  27. };
  28. <em>...</em>
  29. template&lt;&gt; struct <a href="./arg.html" class="identifier">arg</a>&lt;<em>n</em>&gt;
  30. {
  31. template&lt; typename A1,<em>...</em> typename A<em>n</em> &gt;
  32. struct <a href="./apply.html" class="identifier">apply</a>
  33. {
  34. typedef A<em>n</em> type;
  35. };
  36. };
  37. </pre>
  38. </div>
  39. <div class="section" id="id947">
  40. <h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
  41. <p><tt class="literal"><span class="pre"><a href="./arg.html" class="identifier">arg</a>&lt;n&gt;</span></tt> specialization is a <a class="reference internal" href="./metafunction-class.html">Metafunction Class</a> that return the <tt class="literal"><span class="pre">n</span></tt>th of its arguments.</p>
  42. </div>
  43. <div class="section" id="id948">
  44. <h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
  45. <pre class="literal-block">
  46. #include &lt;<a href="../../../../boost/mpl/arg.hpp" class="header">boost/mpl/arg.hpp</a>&gt;
  47. </pre>
  48. </div>
  49. <div class="section" id="id949">
  50. <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
  51. <table border="1" class="docutils table">
  52. <colgroup>
  53. <col width="15%" />
  54. <col width="36%" />
  55. <col width="48%" />
  56. </colgroup>
  57. <thead valign="bottom">
  58. <tr><th class="head">Parameter</th>
  59. <th class="head">Requirement</th>
  60. <th class="head">Description</th>
  61. </tr>
  62. </thead>
  63. <tbody valign="top">
  64. <tr><td><tt class="literal"><span class="pre">n</span></tt></td>
  65. <td>An integral constant</td>
  66. <td>A number of argument to return.</td>
  67. </tr>
  68. </tbody>
  69. </table>
  70. </div>
  71. <div class="section" id="id950">
  72. <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
  73. <p>For any integral constant <tt class="literal"><span class="pre">n</span></tt> in the range [1, <a class="reference internal" href="./limit-metafunction-arity.html">BOOST_MPL_LIMIT_METAFUNCTION_ARITY</a>] and
  74. arbitrary types <tt class="literal"><span class="pre">a1</span></tt>,... <tt class="literal"><span class="pre">an</span></tt>:</p>
  75. <pre class="literal-block">
  76. typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><em>n</em>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;<em>n</em>&gt;,a1,<em>...</em>a<em>n</em> &gt;::type x;
  77. </pre>
  78. <table class="docutils field-list" frame="void" rules="none">
  79. <col class="field-name" />
  80. <col class="field-body" />
  81. <tbody valign="top">
  82. <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
  83. </tr>
  84. <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">x</span></tt> is identical to <tt class="literal"><span class="pre">an</span></tt>.</td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </div>
  89. <div class="section" id="id951">
  90. <h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
  91. <pre class="literal-block">
  92. typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;1&gt;,bool,char,short,int,long &gt;::type t1;
  93. typedef <a href="./apply-wrap.html" class="identifier">apply_wrap</a><tt class="literal"><span class="pre">5</span></tt>&lt; <a href="./arg.html" class="identifier">arg</a>&lt;3&gt;,bool,char,short,int,long &gt;::type t3;
  94. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t1, bool &gt; ));
  95. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; t3, short > ));
  96. </pre>
  97. </div>
  98. <div class="section" id="id952">
  99. <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
  100. <p><a class="reference internal" href="./composition-and-argument-binding.html">Composition and Argument Binding</a>, <a class="reference internal" href="./placeholders.html">Placeholders</a>, <a class="reference internal" href="./lambda.html">lambda</a>, <a class="reference internal" href="./bind.html">bind</a>, <a class="reference internal" href="./apply.html">apply</a>, <a class="reference internal" href="./apply-wrap.html">apply_wrap</a></p>
  101. <!-- Metafunctions/Composition and Argument Binding//protect |60 -->
  102. </div>
  103. </div>
  104. <div class="footer-separator"></div>
  105. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./quote.html" class="navigation-link">Prev</a>&nbsp;<a href="./protect.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./quote.html" class="navigation-link">Back</a>&nbsp;<a href="./protect.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./composition-and-argument-binding.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  106. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  107. Distributed under the Boost Software License, Version 1.0. (See accompanying
  108. file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
  109. </html>