Lazy code generation for C++
- White paper introducing the concept: paper (html)
- My presentation at BoostCon 2011: Slides (pdf)
Frequently Asked Questions
Lazy evaluation vs Lazy Code Generation
These are not the same thing!
Lazy evaluation is a well established technique in C++ used in libraries such as Boost.UBLAS, Armadillo and Eigen. It involves re-ordering the order of operations on objects from the form implied by the usual C++ evaluation and precedence rules to a more efficient order. This technique is implemented through traditional expression templates and is carried out at compile time.
Lazy code generation on the other hand means generating some of the implementation code after compilation time, but before run time.
What are C++ Expression Templates?
Expression templates are a technique for writing C++ code in which the apparent order of evaluation of operations and function calls is changed. It is implemented by replacing operations and function calls by alternative versions which carry with them:
- The operation to be performed
- The data to be operated on
but which do not carry out the actual computation themselves. Instead, the actual computation is carried out once the whole "expression" has been built up.