Main menu

Category Archives: Observation

The project I am working on at the moment contains a fair number of custom less than operators. They are usually required to use non-trivial types (e.g. pointers to structs) as keys in maps – fair enough so far. But what amazes me time and again are the subtle possibilities for failure when crafting one. Some people either seem to be oblivious to the fact that less than needs to induce a strict weak ordering (i.e. if a < b, then under no circumstances can b < a be true), or they don't think their implementation through. Neither do they write a test for it nor get it reviewed. To be fair, the environment favours speed of development somewhat over quality, but I don't think that this provides an entitlement to ignore debug assertions from the STL.
So if you ever find yourself in the situation where you need such an operator, remember – they aren't hard to write, but quite easy to get subtly wrong. And a debug assertion means something is seriously wrong.

Let’s start this blog with something strange that just happened to me:
While being down with flu and severe fever, I noticed that this did not just affect my ability to stand upright and think straight, but altered my very sense of taste. It wasn’t, like some friends in a similar situation reported, a loss of all but the basic tastes, as is often the case with a blocked or inflamed nose, but a shift of tastes.
I first noticed that a dish of red cabbage, usually an explosion of sweet and sour tastes, was dominated by a dark and earthy flavour – a quick check with my wife confirmed that hers tasted as expected, so that must have been me. Later that night, I discovered the toothpaste had taken on a taste of near-unbearable bitterness, whereas fresh water took on some murky taste. Isostar, on the other hand, tasted really great – much better than it ever should taste in real life, even after a hard work-out. Oh, and bananas suddenly had a horrible taste of artificial banana flavour, like the really horrible banana sweets from the 1980s.

Luckily, most of this seems to revert to normal as of this afternoon, which hopefully also means the rest of my body will recover soon.