Tag Archives: C++11
C++20 will come with what we call “Ranges” library. Meanwhile, range interface has been supported ever since C++11 in one context: range-based for loop. A range-based for loop can detect anything that is a range and work with it. In … Continue reading
Let’s start with the problem. I want to check whether a program received a text message that consists of four consecutive zeroes. Not ‘0’, but the numeric zero. I will create a constant std::string representing the special sequence and compare … Continue reading
In this post I would like to discuss two issues brought up by the readers regarding previous posts on using <system_error>: Storing 0 in error codes, and using non-0 success values. Concerns about using globals.
In the previous posts we have seen what error codes and error conditions are. But the way we used them is far from optimum. In particular, the implementation of FailureSourceCategory::equivalent was huge and error category FailureSourceCategory was forced to be … Continue reading
In the previous post we have seen how you can create your own error-code enumeration for representing different reasons for failure in your component, and how you can store them and convey them type erased via std::error_code. In this post … Continue reading
I was recently implementing the “classification of error conditions” in my application offered by the functionality behind std::error_code. In this post I want to share some of my experience and insight. C++11 comes with a quite sophisticated mechanism for classifying … Continue reading
We will start with a bug, taken from real life. It spans across three files: Question: what happens when this program is executed?