• Type safety of .NET delegates vs. C function pointers

    It is often claimed that one of the advantages of the C#/.NET delegate mechanism over C/C++ function pointers is the type safety. This claim is true but not in the obvious way.

    Read more…
  • Implementing RAII and more on smart pointers

    In my last post, I presented the usefulness and necessity of RAII. In this post I want to walk you through the implementation of the second simplest imaginable smart pointer: The scoped_ptr class template should support the * and -> operators, and delete the pointee in its destructor (i.e. when a scoped_ptr object goes out of scope). This is what std::unique_ptr also does, but we will see that our scoped_ptr lacks some of unique_ptr’s features.

    Read more…
  • Erase delete

    tl;dr: The usage of delete in normal C++ code is an anti-pattern. There are ways of managing memory and other resources that are both more comfortable and safer (while maintaining the same performance as manual delete). These techniques go by the name RAII.

    Read more…

subscribe via RSS