4 ms·
It's been ages since I've done metaprogramming with C++. I had to look this up, since my first reaction was: just use recursion! Yeah, I can see why a for-loo
by pragma_x 2y ago
It's been ages since I've done metaprogramming with C++. I had to look this up, since my first reaction was: just use recursion! Yeah, I can see why a for-loop is the preferred way to go here.
Turns out that const-call depth is limited to 512, but by implementation, not by the standard (which is undefined).
https://stackoverflow.com/a/9320911/713831 https://stackoverflow.com/a/9320911/713831
- foota 2y agoThere's a way to "iterate" over parameter packs called fold expressions, but they're painful and look very weird.
- plorkyeran 2y agoI don't find them painful, but they're definitely extremely weird looking. The fact that they're "fold expressions" but are normally used with operator comma to sequence together things that want to be statements is a pretty strong sign that something went wrong in the design process.
- a_t48 2y agoWhen I first touched this around C++14 or so, I used recursion. It resulted in even worse code.