Smart Pointers in C++

Posted by Kaya Kupferschmidt • Saturday, July 9. 2005 • Category: C++
If one is building a complex piece of software with many objects, almost automatically the problem of shared objects arises. That means there exist objects which do not only have one owner, but multiple owners instead - they are shared objects. The difficult question with shared objects is their lifecycle. Once an object is created and bound to different owners, it is not clear any more how and when the object should be removed from memory.

One common approach to this problem is reference counting, that is, each shared object contains a reference counter that is incremented each time the object is bound to a new owner and it is decremented as soon as one of its owners wants to release the object. Using C++ templates the reference counting mechanism can be easily automated by introducing so called smart pointers. The following snippets of code implement both an object with reference counting (which in turn can be used as a base class for many classes) and the basic ideas how to implement a shared pointer.

Continue reading "Smart Pointers in C++"

No Software Patents for Europe

Posted by Kaya Kupferschmidt • Wednesday, July 6. 2005 • Category: Programming
Today the European parliament voted against the directive for software patents. This is a very good thing, there are simply to many risks in software patents, especially for small developers and companies like myself. In the eyes of the vast majority of all developers, only big companies will benefit from software patents, for the following reasons:

  1. Big companies already own a lot of software patents, especially companies loacted in the USA.

  2. Small companies just can't afford to do all the research needed to file a patent

  3. Thus the big companies can control the small ones via their patent portfolio


(The real winners would be the lawyers in the end).

It is also very interesting to see, that most companies which put pressure on the parliament for software patents are located in the USA - so the benefit for Europe would be exactly none, because this way, most European developers would have to pay royalities and license fees to american companies.

But the fight is not over yet: The main reason why the parliament voted against software patents simply is the fact, that both sides were not happy with the last version of the directive. So we can expect that the whole run for and against software patents will restart soon. Hopefully some more members of the parliament listen to the European software companies than last time.

A Simple Sidebar