How to avoid implicit conversion in C++

Exact types of Fasteners
Exact types of Fasteners

nothing_but<T>

Value Handle to Avoid Implicit Conversions in standard C++

Introduction

“… C++ is not a bad language per se. It’s just, well kinda suffers from bloat. In the words of Richard E. Gooch, “It seduces the programmer, making it much easier to write bloatware“…”
The source

Continue reading “How to avoid implicit conversion in C++”

Simple matrix for the rest of us

The Introduction

“…There are issues such as dynamic memory allocation in C/C++, which is forbidden, under the DO-178B standard, in safety-critical embedded avionics code…”
The source

Before knowing the above, the other day I have developed a handy little template to hold and provide, a plain 2d array, completely on the stack (aka the “matrix”).

It is also fully “compile time capable” with the full static internal presentation.

It is very handy to gently enforce company-wide C++ policies and to give some useful functionality in return. I am calling this approach “almost a pod”. Continue reading “Simple matrix for the rest of us”

C++ Inheritance easily grows out of control

Interface inheritance is good.

Inheritance
Parts of your behaviour are inherited from your parents. That is  “interface” inheritance. The interface of your parents defines the part of  your behavior. Just like yours defines the parts of the behaviour of your children.

Update

Just stumbled upon this excellent and succinct short text on how not to use inheritance. In C++ in particular, and I am adding: in general.

The purpose of inheritance in C++ is to express interface compliance (subtyping), not to get code reuse.

That text is precisely about differences v.s. the Objective-C, but it is priceless if and when you spot the growth of the weed of inheritance. Continue reading “C++ Inheritance easily grows out of control”