cplusplus.co.il

Archive for August 2009

Destructors and placement new

Posted by: rmn on: 16/08/2009

When using placement new operator, destruction isn’t as transparent as usual..

Changing the vtable pointer

Posted by: rmn on: 14/08/2009

Most compilers implement dynamic binding by using a vtable whose pointer resides at the beginning of each object’s memory footprint (something along the lines of [vtable-pointer|..members..], if we are not considering virtual inheritance). Keeping this idea in mind, why don’t we go ahead and attempt to change that vtable pointer?

Printing using std::copy

Posted by: rmn on: 14/08/2009

From time to time we are required to print out a vector. It is possible to utilize the standard copy algorithm (std::copy) to do just that.

Computations at compile time

Posted by: rmn on: 13/08/2009

The C++ template mechanism is a very powerful tool. Besides its great ability of code generation, it can also be used to make useful computations at compile time. Let us introduce such an example.

Koenig lookup

Posted by: rmn on: 12/08/2009

What would you expect to happen in the following code?

Constructor selection with virtual inheritance

Posted by: rmn on: 11/08/2009

Virtual inheritance has quite a few common pitfalls, one of which is related to the construction of the virtual base.

The given two statements actually translate to two very different declerations.


Follow

Get every new post delivered to your Inbox.

Join 25 other followers