statement.qbk 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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 Lazy Statements]
  9. Lazy statements? Sure. There are lazy versions of the C++ statements we all know
  10. and love. For example:
  11. if_(arg1 > 5)
  12. [
  13. std::cout << arg1
  14. ]
  15. Say, for example, we wish to print all the elements that are greater than 5
  16. (separated by a comma) in a vector. Here's how we write it:
  17. std::for_each(v.begin(), v.end(),
  18. if_(arg1 > 5)
  19. [
  20. std::cout << arg1 << ", "
  21. ]
  22. );
  23. (See [@../../example/if.cpp if.cpp])
  24. [blurb __tip__ Learn more about statements [link phoenix.modules.statement here.]]
  25. [endsect]