Tags » RAII

Provide access to raw resources in resource-managing classes

  1. To do this is necessary to convert an object of the RAII class into the raw resource it contains.
  2. There are two general ways to do it: explicit conversion and implicit conversion.
  3. 43 more words
Effective C++

Think carefully about copying behavior in resource-managing classes

  1. When smart pointers are inappropriate resource handlers for our context, we need to create our own resource-managing classes. But what should happen when a RAII object is copied?
  2. 56 more words
Effective C++

Use objects to manage resources

  1. When using raw resources there are several ways the release of the resource could fail.
  2. To make sure that a raw resource is always released, we need to put that resource inside an object whose destructor will automatically release the resource.
  3. 107 more words
Effective C++

Rule -1: No dynamic allocation unless necessary

Recently on StackOverflow, an original poster found memory leaks in C++ code. It is easy to spot that there is a raw new without delete… 124 more words

Comma Operator RAII Abuse

Here’s a neat little trick that one of my co-workers, Clint Levijoki, discovered. In C++ you often use an RAII wrapper that you place on the stack if you want to be sure that code gets run at a later point. 519 more words


Mining "Effective C++" for ideas on Swift

Effective C++ by Scott Meyers is an amazingly good book. For me, it is to programming books like Watchmen is to comics – everything else I read, I feel disappointed that it isn’t as good. 1,328 more words