Strings vs. Enumerators
Sometimes, a fixed set of string values is allowed as input. Often these string values are then stored, used for control flow etc. Enumerators are a better alternative.
Sometimes, a fixed set of string values is allowed as input. Often these string values are then stored, used for control flow etc. Enumerators are a better alternative.
I’ll try something new today: I pick a piece of code from the web and see what improvements I would make to it, using small refactoring steps.
C++ programmers often praise their statically typed language. Having a compilation phase with the possibility to statically check for possible errors is a feature that makes good for the time […]
In the last two posts I have written about compiler warnings. There’s much more to getting hints about code smells and potentially problematic pieces of code than that. That’s the job […]
In the last post I wrote about how to change our code to avoid getting compiler warnings. Sometimes that is not a feasible approach and we need to tell your compiler […]
We often see compiler warnings about pieces of code that have potential problems or poor style. Sometimes they point out code that is actually wrong, so don’t ignore them.
Move constructors are often cheaper than copy constructors, which makes the construction and immediate relocation of objects in modern C++ more effective than in C++03. However, just moving the parts needed to construct the object in the right place can be even more effective. Several standard library functionalities use perfect forwarding to construct objects right where they are needed.
Sometimes we fail to acquire a needed resource or responsibility during the construction of an object. Sometimes the construction of a subobject fails. How can we deal with an incompletely […]
Some of the most surprising bugs I have come across happened when someone (often enough myself) accessed an object outside of its lifetime. There are some pitfalls, common misunderstandings and […]
I have written about handling exceptions some time ago, and about the levels of exception safety last week. What I have not touched yet are exception specifications. I will catch […]