A question of memory layout

January 20th, 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?

« Read the rest of this entry »

Tuples

January 15th, 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 multiple values from a function through a tuple, or write more intuitive and expressive code by utilizing tuples.

In this post we will examine the functionality offered by the new Tuple container, and have a go at profiling its performance. Actually, the results of said profiling were a small (pleasant) surprise to me.

« Read the rest of this entry »

Memoization

January 7th, 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. Why don’t we generalize it further, and supply a generic, reusable, solution for Memoization?

« Read the rest of this entry »

Tag dispatching

January 3rd, 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.

« Read the rest of this entry »

The omnipotent arrow operator

December 28th, 2009 § 2 Comments

Are you familiar with the new, all-mighty, arrow “–>” operator in C++ ?

#include <iostream>

int main () {
    unsigned count = 30;
    while (count --> 0) // count goes to zero
        std::cout << count << std::endl;
}

« Read the rest of this entry »