4 ms·
At first I was going to say that it's similar to asm.js - that it enabled an optimization but also could fall back to just running the code. However in trying
by phaedrus 9y ago
At first I was going to say that it's similar to asm.js - that it enabled an optimization but also could fall back to just running the code. However in trying to find references to back up my answer, I found a different explanation of constexpr which changed my own understanding.
https://stackoverflow.com/questions/38879475/why-cant-constexpr-just-be-the-default https://stackoverflow.com/questions/38879475/why-cant-conste...
Quoting Ben Voigt: "What constexpr does is provide guarantees on what data-flow analysis a compliant compiler is required to do to detect1 compile-time-computable expressions, and also allow the programmer to express that intent so that they get a diagnostic if they accidentally do something that cannot be precomputed."