What about using `if constexpr`? Sure, there currently are no equivalent constant variables to use, but adding those should be very easy.
Re:C++ Modules Might Be Dead-On-Arrival
by stochastic_monk on Monday January 28, 2019 @08:18AM
(#19017179)
if constexpr only works for procedural code, not data members. (e.g., use __m128i v[4] for SSE2, __m256 v[2] for __AVX2__, etc.) It could be templated, as long as there was a compile-time method besides the CPP to get architectural information, so that would be a way (if much more verbose) forward.
That being said, if constexpr is great; iterating over either sparse or dense arrays with in Blaze without wrapping in two functions was mind-blowing when I discovered I could so easily.
That is why static if and version in D work very differently. Alexei Alexandescu criticized if constexpr in C++ for being a poor copy of static if that misses the point, but that was dismissed. But it is powerful enough to handle almost all cases of conditional compilation.
Isn't C++ supposed to be object-oriented? Why you couldn't have specific class optimized for each architecture?
Like when one does proper C or C++ clean coding without pre-processor spaghetti, an implementation file for each architecture or OS specific coding.
Re:C++ Modules Might Be Dead-On-Arrival
by MrStonedOne on Monday January 28, 2019 @05:26AM
(#19016386)
So, copy and pasted code spread out everywhere rather than centralized?
Not at all, fine tuned in small functions or architecture specific headers.
Re:C++ Modules Might Be Dead-On-Arrival
by banachtarski on Monday January 28, 2019 @05:39AM
(#19016430)
Yes thank you. Not to mention that the parent comment neglects the fact that splitting out files just means you have to now worry about conditional inclusion or tighter coupling with your build system.
That approach has successfully turned a pile of spaghetti C pre-processor code into a managable secure server application deployed across Aix, HP-UX, Solaris, Linux and Windows NT/2000.
Yes it was tighly coupled with Make that took care of selecting the proper set of files to compile and link based on the platform.
The anti-module crowd seems to want to have it all, which to me is the same anti-exceptions and anti-RTTI crowd, and in that case modules are indeed dead-on-arrival.
> That approach has successfully turned a pile of spaghetti C pre-processor code into a managable secure server application deployed across Aix, HP-UX, Solaris, Linux and Windows NT/2000.
I have also weitten and deployed what you’re denigrating as “preprocessor spaghetti code” across the above exact platforms, with a lot of success.
Perhaps we work(ed) at the same company.
It’s archaic and low level, but it’s also powerful and expressive. Replacing the CPP would probably just require a new language.