In software engineering it is important to fail early and loudly, when problems are detected. Meaning that your program should report problems that, if left unsolved can lead to undefined behavior, as early as possible and in a way that is visible. This makes problems easy to detect and fix as soon as possible.
The earlier you can detect a problem is at compile time, and the “loudest” is to produce a compile error. Wouldn’t it be wonderful if you where sure your program was correct if it compiled?
We are familiar with assertions that are performed at runtime, methods like assert() can validate if we have a state that we can not meaningfully recover from and prevent an program from continuing to execute.
Continue reading Compile time assertions