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

Programming

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

Swift

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

C++

Smart Pointers

Smart Pointers

In modern C++ programming, the Standard Library includes smart pointers, which are used to help ensure that programs are free of memory and resource leaks and are exception-safe. 530 more words

Algorithm

Resource handling and move semantics

Techniques to automatically manage the run-time lifetime of resources include reference counting, where multiple references to the same resource exist and ownership transfer where only a single reference to a resource at any given time exists. 2,098 more words

C++