diff --git a/doc/index.html b/doc/index.html index e68a6ea..41cead5 100644 --- a/doc/index.html +++ b/doc/index.html @@ -12,7 +12,7 @@ is granted, provided this copyright notice appears in all copies, and a notice that the code was modified is included with the copyright notice. -


Table of Contents

1. In a nutshell
2. Getting Started
2.1. Installing the library
3. Introduction
3.1. Motivation
3.2. Introduction to lambda expressions
4. Using the library
4.1. Examples
4.2. Parameter and return types of lambda functors
4.3. About actual arguments to lambda functors
4.4. Storing bound arguments in lambda functions
5. Lambda expressions in details
5.1. Placeholders
5.2. Operator expressions
5.3. Bind expressions
5.4. Overriding the deduced return value
5.5. Extending return type deduction system
5.6. Delaying constants and variables
5.7. Control expressions
5.8. Exceptions
5.9. Construction and destruction
5.10. Special lambda expressions
6. Contributors

NOTE!

+


Table of Contents

1. In a nutshell
2. Getting Started
2.1. Installing the library
3. Introduction
3.1. Motivation
3.2. Introduction to lambda expressions
4. Using the library
4.1. Examples
4.2. Parameter and return types of lambda functors
4.3. About actual arguments to lambda functors
4.4. Storing bound arguments in lambda functions
5. Lambda expressions in details
5.1. Placeholders
5.2. Operator expressions
5.3. Bind expressions
5.4. Overriding the deduced return value
5.5. Extending return type deduction system
5.6. Delaying constants and variables
5.7. Control expressions
5.8. Exceptions
5.9. Construction and destruction
5.10. Special lambda expressions
6. Contributors

NOTE!

At the moment, the documentation is a draft. Exceptions, control constructs, advanced bind expressions (nesting binds etc.), constructor and destructor calls and a few other things are not documented yet. @@ -926,9 +926,75 @@ This does not hold for compound assignment operators +=, -= et Nevertheless, it is perfectly ok to delay the left operand explicitly. For example, i += _1 is equivalent to var(i) += _1.

5.7. Control expressions

-BLL defines several functions to create lambda functors for control expressions. -They all take lambda functors as parameters and return void. -

5.8. Exceptions

5.9. Construction and destruction

5.10. Special lambda expressions

5.10.1. Protect

5.10.2. Const_parameters

5.10.3. Break_const

5.10.4. Unlambda

6. Contributors

+BLL defines several functions to create lambda functors that represent control constructs. +They all take lambda functors as parameters and return void. +To start with an example, the following code outputs all even elements of some container a: + +
+for_each(a.begin(), a.end(), 
+         if_then(_1 % 2 == 0, cout << _1));  
+
+

+The BLL supports the following function templates for control structures: + +

+if_then(condition, then_part)
+if_then_else(condition, then_part, else_part)
+while_loop(condition, body)
+while_loop(condition) // no body case
+do_while_loop(condition, body)
+do_while_loop(condition) // no body case 
+for_loop(init, condition, increment, body)
+for_loop(init, condition, increment) // no body case
+switch_statement(...)
+
+

+Delayed variables tend to be commonplace in control lambda expressions. +For instance, here we use the var function to turn the arguments of for_loop into lambda expressions. +The effect of the code is to add 1 to each element of a two-dimensional array: + +

+int a[5][10]; int i;
+for_each(a, a+5, 
+  for_loop(var(i)=0, var(i)<10, ++var(i), 
+           _1[var(i)] += 1));  
+
+ +As explained in Section 5.6, we can avoid the repeated use of wrapping of var if we define it beforehand: + +
+int i;
+var_type<int>::type vi(var(i));
+for_each(a, a+5, 
+  for_loop(vi=0, vi<10, ++vi, _1[vi] += 6));  
+
+ +

5.7.1. Switch statement

+The lambda expressions for switch control structures are more complex since the number of cases may vary. +The general form of a switch lambda expression is: + +

+switch_statement(condition, 
+  case_statement<label>(lambda expression),
+  case_statement<label>(lambda expression),
+  ...
+  default_statement(lambda expression)
+)
+
+ +The condition argument must be a lambda expression that creates a lambda functor with an integral return type. +The different cases are created with the case_statement functions, and the optional default case with the default_statement function. +The case labels are given as explicitly specified template arguments to case_statement functions and +break statements are implicitly part of each case. +For example, case_statement<1>(a), where a is some lambda functor, generates the code: + +
case 1: 
+  evaluate lambda functor a; 
+  break;
+
+We have specialized the switch_statement function for up to 9 case statements. + +

5.8. Exceptions

5.9. Construction and destruction

5.10. Special lambda expressions

5.10.1. Protect

5.10.2. Const_parameters

5.10.3. Break_const

5.10.4. Unlambda

6. Contributors

Jaakko Järvi, Gary Powell. Additional help and ideas: Jeremy Siek, Peter Higley, Peter Dimov