Tags » RAII

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


std::ios_base format flags are a resource that needs RAII

Suppose we wanted to write a class Fraction which would come equipped with an input operator>> that would accept input in the form -2/4 or… 1,272 more words