Collection iteration is perhaps the most insidious language construct. Simple to create and easy to understand. Yet lurking within lies the ability to create random non-local defects. Monstrous bugs that you’ll spend […]
Obtaining a ‘shared_ptr’ from ‘this’ is possible using the ‘enable_shared_from_this’ class. It’s a feature that allows a class to reference itself within a smart pointer based API. Beware an ugly implementation detail […]
Smart pointers in C++ are nice, yet fraught with irregularities. One is the inability to create a proper clone function. This requires a feature called covariant return types, which C++ supports, but […]
C++11 introduced a perfect forwarding mechanism for template parameters. The key part is the ability for a template parameter to match any input without any implicit conversion. This is done using the […]
Does ‘return’ always cause a function to return? Surprisingly the answer is “no”. Indeed there are situations in which ‘break’ may not always break from a loop, and ‘goto’ may no go […]
There’s something wrong when a language allows 1/2 to equal 0. It’s easy to understand why this happens, and perhaps it’s even easy to forgive the limitations of C. Nonetheless it’s irksome […]
One of the problems with C++ is the way it handles type conversion. It inherits a lot of implicit conversion from C and then adds on additional conversions. The problem with all […]
Casting in C++ is a confusing jumble of unclear and dangerous operations. It mixes unrelated concepts. It introduces ambiguities and redundancies. It’s an essential but flawed aspect of the language.
Efficient yet confused. Powerful but unsafe. So is the nature of C++ object allocation and instantiation.
C introduced it and C++ mastered it. The hellish world of implicit conversion and type promotion. A system which silently modifies, truncates, rounds, and otherwise mangles our variables.