Tag Archives: C++03
(Not) detecting bugs
The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most … Continue reading
The One-Definition Rule
We have been hit by the same bug twice already this year. It ends in a crash, and it took developers days to find it (in each case), even though it is reproducible on each run of unit tests. The … Continue reading
A customizable framework
In this post I want to describe a problem my colleagues have faced a couple of times recently, and show how it can be solved with C++. Here is the goal. We want to provide a function (or a set … Continue reading
Overload resolution
This post is an introduction to another one that I intend to write in the future. The goal of this one is to go over the concepts of function template specialization, function (template) overloading, argument dependent lookup (ADL) and overload … Continue reading
More than you need
The classes you design can do more (in terms of allowed operations) than what you could figure out from just looking at their member function declarations. The C++ Standard defines a number of cases where certain expressions involving your type … 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
Handling short codes — part II
Today, we will continue with the implementation of a type capable of storing short codes. For the previous post on the subject see here. This time, we will focus on type safety.
Handling short codes — part I
In my work, we often deal with codes: country codes, airport codes, airline codes, aircraft codes, and more. The thing they have in common is that they are really short. Sometimes 2-letter long, sometimes 3-letter long, sometimes a bit longer. … Continue reading
A clever comment style
Comments are one of the most useful language features; in practically any programming language. Yet, they can become really a pain. Just consider the following example that I have seen quite often in different variations: or: You could surely give … Continue reading