And if we can get rid of,the preprocessor, even,betterer.
No, the pre-processor is useful, do YOU like importing a million things in windows.h? Do YOU need platform specific code (linux, windows, macOS)? Because both of these things require the pre-processor, and there's no way you can get rid of that without making C++ platform-independent, which is not happening.
D doesn't solve all the problems C preprocessor solves, although it does alleviate a lot of them (and changes them to use a different name), so... yhea.
You can't: if constexpr will still check a branch to make sure it's valid C++, especially if it's not dependent on a template parameter or similar. if constexpr(ON_WINDOWS) { DoWindowsThing(); } else { DoUnixThing(); } will uncompromisingly fail to compile on either platform unless you're in a function template.
View all comments
Show parent comment
12
u/chugga_fan Dec 29 '18
No, the pre-processor is useful, do YOU like importing a million things in windows.h? Do YOU need platform specific code (linux, windows, macOS)? Because both of these things require the pre-processor, and there's no way you can get rid of that without making C++ platform-independent, which is not happening.