3 ms·
In this case this doesn't work because "if constexpr" parses both branches. If the new library version changes function signatures, the if-branch for the old li
by flohofwoe 6y ago
In this case this doesn't work because "if constexpr" parses both branches. If the new library version changes function signatures, the if-branch for the old library version produces an error:
https://www.godbolt.org/z/4KK997 https://www.godbolt.org/z/4KK997
PS: interesting to note that Zig does the "right thing":
https://www.godbolt.org/z/9c13PY https://www.godbolt.org/z/9c13PY
- mhh__ 6y agoThere was a proposal to do the correct thing and copy D's static if, but it was rejected for fairly contrived reasons IIRC. Andrei Alexandrescu mentions it in a talk, if constexpr doesn't really do much of anything useful because it introduces a scope.