It is relatively easy to get your for-loops wrong. Luckily, C++ offers more and more bug-proof alternatives. The post is available at the new blog location: https://thecppway.com/posts/structured_iteration/.
I have decided to move Andrzej’s C++ blog to a new location. It is now at https://thecppway.com and has been rebranded to The C++ way. You will now get a more modest experience, but without disturbing advertisements and with the … Continue reading →
This post is in response to two claims about coroutines: Their reference function parameters may become dangling too easily. They are indistinguishable from regular functions from the declaration alone. But rather than talking about coroutines, we will look at event-driven … Continue reading →
What is the difference between a concept and a type trait? Note that you can create a type trait using a requires-expression: You can also constrain a template with a type trait using a requires-clause: There are differences though. Some … Continue reading →
The primary motivation for defining a class in C++ is to reflect and maintain a class invariant. In this post we will see what class invariants are and how you deal with them. Class invariants are important part of C++, … Continue reading →
Some common knowledge: the lifetime of the object starts when its initialization is complete. Based on this we can get some further expectations: an object becomes const only after its initialization is complete. But this lifetime property of objects becomes … Continue reading →
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 →
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 →
In this post we will see how to solve the task from the previous post, but display the time point in local time instead of system time. The solution is simple and takes only two additional lines (you can scroll … Continue reading →
The goal of this post is to show how the <chrono> library can be used to solve a practical but not that obvious problem. There is a lot of good material in the Internet where one can learn <chrono> from, … Continue reading →