Posts
-
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
Read more…scoped_ptr
class template should support the*
and->
operators, and delete the pointee in its destructor (i.e. when ascoped_ptr
object goes out of scope). This is whatstd::unique_ptr
also does, but we will see that ourscoped_ptr
lacks some ofunique_ptr
’s features. -
Erase delete
tl;dr: The usage of
Read more…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 manualdelete
). These techniques go by the name RAII.
subscribe via RSS