On 9/04/2019 13:40, Robert Ramey wrote:
Why not use #ifndef JUNIOR_DEVS_DONT_TOUCH or something similarly never defined (and so never disabling the check) but expressing your real intent? -1
I don't particularly agree with that either, but that's what Niall said was the real reason for the #ifdef. I did paraphrase, of course. FWIW though I don't think it was intended as a disparagement of junior developers in particular. It's easy enough for anyone, no matter how junior or senior, to trip over an assumption in the code -- and in that case it's best if the assumption is declared in a fashion that the compiler can alert you about, so that you can decide if the violation was intentional or not and correct related code accordingly if needed.
a) I think you're doing it basically right b) It's a mistake to characterize this iast "protection against other developers. Actually it could be considered offensive to other developers. We all need to do our part for creating a safe space for those other developers. c) It's better to see it as using the compiler to explicity enforce type requirements in order to get correct code.
It's better to have the static_asserts without any #if at all. (Unless, as I said, there's a fundamental requirement for it, eg. with types changing size in debug builds.)