/Src/Dependencies/Boost/libs/phoenix/doc/html/phoenix/starter_kit/arguments.html

http://hadesmem.googlecode.com/ · HTML · 75 lines · 75 code · 0 blank · 0 comment · 0 complexity · 505a1a42344ad71d690a5871e95739d8 MD5 · raw file

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Arguments</title>
  5. <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
  7. <link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.0">
  8. <link rel="up" href="../starter_kit.html" title="Starter Kit">
  9. <link rel="prev" href="references.html" title="References">
  10. <link rel="next" href="lazy_operators.html" title="Lazy Operators">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="references.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../starter_kit.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lazy_operators.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h3 class="title">
  27. <a name="phoenix.starter_kit.arguments"></a><a class="link" href="arguments.html" title="Arguments">Arguments</a>
  28. </h3></div></div></div>
  29. <p>
  30. Arguments are also functions? You bet!
  31. </p>
  32. <p>
  33. Until now, we have been dealing with expressions returning a nullary function.
  34. Arguments, on the other hand, evaluate to an N-ary function. An argument
  35. represents the Nth argument. There are a few predefined arguments arg1, arg2,
  36. arg3, arg4 and so on (and it's <a href="http://www.boost.org/libs/lambda/doc/index.html" target="_top">BLL</a>
  37. counterparts: _1, _2, _3, _4 and so on). Examples:
  38. </p>
  39. <pre class="programlisting"><span class="identifier">arg1</span> <span class="comment">// one-or-more argument function that returns its first argument
  40. </span><span class="identifier">arg2</span> <span class="comment">// two-or-more argument function that returns its second argument
  41. </span><span class="identifier">arg3</span> <span class="comment">// three-or-more argument function that returns its third argument
  42. </span></pre>
  43. <p>
  44. <code class="computeroutput"><span class="identifier">argN</span></code> returns the Nth argument.
  45. Examples:
  46. </p>
  47. <pre class="programlisting"><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span>
  48. <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">s</span> <span class="special">=</span> <span class="string">"Hello World"</span><span class="special">;</span>
  49. <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg1</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 3
  50. </span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">arg2</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints "Hello World"
  51. </span></pre>
  52. <p>
  53. (See <a href="../../../../example/arguments.cpp" target="_top">arguments.cpp</a>)
  54. </p>
  55. <div class="sidebar">
  56. <div class="titlepage"></div>
  57. <p>
  58. <span class="inlinemediaobject"><img src="../../images/tip.png" alt="tip"></span> Learn more about arguments <a class="link" href="../modules/core/arguments.html" title="Arguments">here.</a>
  59. </p>
  60. </div>
  61. </div>
  62. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  63. <td align="left"></td>
  64. <td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010 Joel de Guzman, Dan Marsden, Thomas Heller<p>
  65. Distributed under the Boost Software License, Version 1.0. (See accompanying
  66. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  67. </p>
  68. </div></td>
  69. </tr></table>
  70. <hr>
  71. <div class="spirit-nav">
  72. <a accesskey="p" href="references.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../starter_kit.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="lazy_operators.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  73. </div>
  74. </body>
  75. </html>