arguments.qbk 1.4 KB

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