PageRenderTime 30ms CodeModel.GetById 27ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://hadesmem.googlecode.com/
text | 35 lines | 25 code | 10 blank | 0 comment | 0 complexity | 947ed9d3de973edb3fd001f08f0a9011 MD5 | raw file
 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
12Arguments are also functions? You bet!
13
14Until now, we have been dealing with expressions returning a nullary function.
15Arguments, on the other hand, evaluate to an N-ary function. An argument
16represents the Nth argument. There are a few predefined arguments arg1,
17arg2, arg3, arg4 and so on (and it's __bll__ counterparts: _1, _2, _3, _4 and so
18on). 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]