Subscribe
- Follow Andrzej's C++ blog on WordPress.com
-
Recent Posts
Archives
Tag Archives: resource handling
A moved-from optional
This post is in response to claims, that I have heard number of times, that the semantics of optional’s move operations are wrong: Some people are surprised that the second assert holds: the unfulfilled expectation is that moving from an … Continue reading
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 correctness, destructors, exception handling, resource handling
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 correctness, destructors, exception handling, resource handling
7 Comments
Rvalues redefined
In this post we will explore what I consider the most significant language change in C++17. I call it the most significant because it changes the way you design your resource-managing types and how you think about initialization. It is … Continue reading
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
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
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
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 C++03, C++11, correctness, exception handling, resource handling
43 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