Tag Archives: destructors

The obvious final step

The title may be misleading, as I had to invent a new short term for the pattern that occurs in the code once in a while. Example first: During the construction of an XML file when you write an element, … Continue reading

Posted in programming | Tagged , , , | 12 Comments

Operation cancelling and std::fstream

In the previous post we have sketched out the view that error handling is about expressing the success dependency between operations. I have also indicated the guideline “destructors only for releasing resources”. In this post we are going to see … Continue reading

Posted in programming | Tagged , , , | 11 Comments

Handling errors is canceling operations

I actually covered this topic before, in this post, but given my recent experience I feel it needs reiterating and a bit of restructuring. It boils down to the observation that any error handling I have encountered — be it … Continue reading

Posted in programming | Tagged , , , | 7 Comments

Sessions and object lifetimes

In this post we will see how C++ object lifetime can be used to control the duration of sessions: time spent owing and using a resource. The goal is to get a better understanding of what tools the language offers … Continue reading

Posted in programming | Tagged , , , | 6 Comments

Destructors — 2 use cases

In this post I want to describe an interesting observation: programmers generally use destructors for two purposes. One is fairly obvious: releasing resources; the other — not necessarily so.

Posted in programming | Tagged , , , | 3 Comments

noexcept destructors

The goal of this post is to show one — fairly small — backwards incompatibility in C++11. It shows how noexcept exception specifications are implicitly generated for your destructors. In short, the following program used to run successfully in C++03 … Continue reading

Posted in programming | Tagged , , , | 23 Comments

C++’s best feature

Update. My remark on exceptional life-time of temporaries in array initialization was incorrect. This part is now fixed. I also included some essential information, as suggested by Herb Sutter. C++, if you want to learn all of it, is big, … Continue reading

Posted in programming | Tagged , , , | 34 Comments

Destructors that throw

Have you already heard that your destructors had better not throw exceptions? You probably did, because this is what nearly every C++ programmer is taught. But because it is so obvious, it may have escaped your notice that C++, and … Continue reading

Posted in programming | Tagged , , , , | 16 Comments