1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 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.79.1"> 7<link rel="home" href="../../index.html" title="Chapter 1. Phoenix 3.2.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</span> 40<span class="identifier">arg2</span> <span class="comment">// two-or-more argument function that returns its second argument</span> 41<span class="identifier">arg3</span> <span class="comment">// three-or-more argument function that returns its third argument</span> 42</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"><<</span> <span class="identifier">arg1</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 3</span> 50<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</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"><<</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"</span> 51</pre> 52<p> 53 (See <a href="../../../../example/arguments.cpp" target="_top">arguments.cpp</a>) 54 </p> 55<div class="blurb"> 56<div class="titlepage"><div><div><p class="title"><b></b></p></div></div></div> 57<p> 58 <span class="inlinemediaobject"><img src="../../images/tip.png"></span> 59 Learn more about arguments <a class="link" href="../modules/core/arguments.html" title="Arguments">here.</a> 60 </p> 61</div> 62</div> 63<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 64<td align="left"></td> 65<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas 66 Heller, John Fletcher<p> 67 Distributed under the Boost Software License, Version 1.0. (See accompanying 68 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>) 69 </p> 70</div></td> 71</tr></table> 72<hr> 73<div class="spirit-nav"> 74<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> 75</div> 76</body> 77</html> 78