]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/============================================================================== |
2 | Copyright (C) 2001-2010 Joel de Guzman | |
3 | Copyright (C) 2001-2005 Dan Marsden | |
4 | Copyright (C) 2001-2010 Thomas Heller | |
5 | ||
6 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
7 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
8 | ===============================================================================/] | |
9 | ||
10 | [section Arguments] | |
11 | ||
12 | Arguments are also functions? You bet! | |
13 | ||
14 | Until now, we have been dealing with expressions returning a nullary function. | |
15 | Arguments, on the other hand, evaluate to an N-ary function. An argument | |
16 | represents the Nth argument. There are a few predefined arguments arg1, | |
17 | arg2, arg3, arg4 and so on (and it's __bll__ counterparts: _1, _2, _3, _4 and so | |
18 | on). Examples: | |
19 | ||
20 | arg1 // one-or-more argument function that returns its first argument | |
21 | arg2 // two-or-more argument function that returns its second argument | |
22 | arg3 // three-or-more argument function that returns its third argument | |
23 | ||
24 | `argN` returns the Nth argument. Examples: | |
25 | ||
26 | int i = 3; | |
27 | char const* s = "Hello World"; | |
28 | std::cout << arg1(i) << std::endl; // prints 3 | |
29 | std::cout << arg2(i, s) << std::endl; // prints "Hello World" | |
30 | ||
31 | (See [@../../example/arguments.cpp arguments.cpp]) | |
32 | ||
33 | [blurb __tip__ Learn more about arguments [link phoenix.modules.core.arguments here.]] | |
34 | ||
35 | [endsect] |