No implicit conversion from ‘T **’ to ‘const T **’

For a type T, C++ allows an implicit conversion from T* to const T*. This is safe and you most likely used it hundreds of times before (think method calls with const pointer parameters). But if you try it with a double pointer (e.g. implicitly converting T** to const T**) it will fail. gcc for example will tell you something in the lines of:

Have you ever wandered why this is unsafe and wrong and so reported as a compile time error? Continue reading No implicit conversion from ‘T **’ to ‘const T **’

Yoda conditions

I never liked, agreed with or used these much until I found them as a rule in a “coding practices” document lately, document that I’m supposed to be following. Luckily, it’s just an optional rule…
So what is a Yoda condition? It’s a practice of reversing the normal order of the operands in an equality condition and placing the constant (or, more generally, something that is not an LHS expression) on the left of the operator; instead of writing for example Continue reading Yoda conditions