4 ms·
The terms "macro" and "metaprogramming" already have well-defined meanings in the C++ community. You're just hijacking the terms and using them with some new de
by cornstalks 2y ago
The terms "macro" and "metaprogramming" already have well-defined meanings in the C++ community. You're just hijacking the terms and using them with some new definition.
The C++ standard is consistent in how it uses "macro," and it's strictly about the preprocessor kind of macros. "Metaprogramming" is also used in the standard, though not as extensively or rigidly (only 8 times in N4950), but both in the specification and colloquially it's more than just slapping consteval on a function.
- pjmlp 2y agoYeah, because using preprocessor macros would do the trick. /s
- foundry27 2y agoIt actually would! There are a handful of base-10 arbitrary precision arithmetic implementations in the preprocessor[1], and modern continuation-passing style macro metaprogramming[2] makes it straightforward to write a function like factorial once you get the syntax and semantics down. Libraries like Boost.Preprocessor can’t be taken as an example of “cutting edge” preprocessor metaprogramming. It set a very low bar, and IMO has stifled a lot of developer creativity. [1] https://github.com/rofl0r/chaos-pp/tree/master/chaos/preprocessor/arbitrary https://github.com/rofl0r/chaos-pp/tree/master/chaos/preproc... [2] https://github.com/rofl0r/order-pp/blob/master/example/fibonacci.c https://github.com/rofl0r/order-pp/blob/master/example/fibon...
- gpderetta 2y agoI Remember Chaos and Order (20 years ago... now I feel old). The reason that they remained niche is that at the time MSVC had an extremely non confirming preprocessor and advanced PP libraries just weren't viable there. Boos.PP was the most advanced you could get while staying portable.
- gpderetta 2y agoWhile I agree regarding the macro term, consteval very much count as metaprogramming in C++. There is no reason to encode value computations using template expansion anymore. Even a lot of type level computation can be done via plain function calls and decltype. "Old school" recursive template installation is really only needed when you need specifically the capability to pattern match on types of template specialization.