Tag Archives: resource handling

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

Declaring the move constructor

Update. I have updated the post a bit, as it misled a number of people to think that you need to define the move constructor in a cpp file. This is not so. I have now also highlighted another important … Continue reading

Posted in programming | Tagged , , , | 11 Comments

Set-up and tear-down

Recently as part of program run-time performance optimization effort, I was scanning through the code for occurrences of keyword new. The goal was to find unnecessary memory allocations. I was surprised to find most of news in the unit test … Continue reading

Posted in programming | Tagged , , | 5 Comments

noexcept — what for?

In this post I would like to share my observation on where using noexcept really adds value. It is less often than what one might expect, and it does not have that much to do with throwing or not throwing … Continue reading

Posted in programming | Tagged , , , , | 33 Comments

Common optimizations

Language designers, compiler and library vendors make a great effort to make your programs run faster and faster. This post is a tour of some common performance optimizations in C++. Consider the following code that deals with std::string: std::string is … Continue reading

Posted in programming | Tagged , , , | 28 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

(Not) using std::thread

This post is about std::thread but not about threads or multi-threading. This is not an introduction to C++ threads. I assume that you are already familiar with Standard Library components thread and async. I encountered a couple of introductions to … Continue reading

Posted in programming | Tagged , , , | 30 Comments