Archive for the ‘cpp’ Category
Escaping overloaded operators
Posted on: 19/02/2010
- In: tricks
- 6 Comments
The possibility of overloading just about any C++ operator and having it do something entirely different from what it was designed for, can sometimes make life pretty hard.
Here are a couple of examples: What if you wanted to take the address of an object, which had implemented an entirely different semantic for the ampersand (&) operator? Or what if somebody decided to overload the comma operator in some strange manner?
As you could have guessed, there are solutions for such scenarios.
A question of memory layout
Posted on: 20/01/2010
- In: questions
- 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 on: 15/01/2010
- In: tr1
- 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 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.
Memoization
Posted on: 07/01/2010
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?
Tag dispatching
Posted on: 03/01/2010
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.
Recent comments