The powerful template mechanism of C++ allows us to write pretty complex Meta Functions, which are executed by the compiler during compilation. There are two basic types of meta-functions: one whose result is a type (mainly dealt with by Boost.MPL), and the other is a compile-time computation (which can result in any compile time constant). [...]
Archive for January, 2010
A question of memory layout
Posted in questions on 20/01/2010 | 6 Comments »
Actual object memory layout can be a little tricky when inheritance and its virtual tables are involved. And it gets even trickier when pointer arithmetic is employed. Do you consider yourself a low-level expert?
Tuples
Posted in tr1 on 15/01/2010 | Leave a Comment »
One of the containers introduced within TR1 (which is already widely available – both in gcc and Visual Studio) is a Tuple type, which is adopted from The Boost Tuple Library. Tuple types are very convenient at times; For example, it is possible to return multipe values from a function through a tuple, or write [...]
Memoization
Posted in techniques on 07/01/2010 | 10 Comments »
Memoization is essentially a fancy name for caching results for future use. A generalization of dynamic programming, if you will. While I am certain most of us use it one way or another, in many occasions, it is usually through an Ad hoc implementation.. One that is only suitable for the specific, current, use case. [...]
Tag dispatching
Posted in techniques on 03/01/2010 | Leave a Comment »
Tag dispatching is a technique for compile time dispatching between a few overloaded functions by using the properties of a type. This technique usually involves some kind of type traits.