Meta-Programming using C++ templates
A while ago, at the beginning of the current semester, I posted a source code snippet which demonstrated the very basics of a technique called meta-programming. The term “meta programming” describes the creation of programm code that produces programm code itself during compile-time.
In C++ mainly features of template programming and template specialization are used to create meta programms. The meta programms featured in the code snippet calculates sums of numbers from 1 to a given parameter or the value of the fibonacci-sequence to a given index.
The evaluation of the fibonacci numbers for example is executed during compile-time which results in a constant runtime, not depending on the index for the sequence to be evaluated. Of course this technique can only be used to solve static problems.
About this entry
You’re currently reading “Meta-Programming using C++ templates,” an entry on Michael’s Weblog
- Published:
- 08.11.06 / 1am
- Category:
- Programming, Computer science
No comments
Jump to comment form | comments rss [?] | trackback uri [?]