Why is template metaprogramming so complicated? Because the C++ template feature was never designed for this purpose. It just happened to be possible.

[...]

The D language allows compile-time if statements (called static if), but no compile-time loops. We can only hope that such a feature becomes available in the future. If a future version of C++ should allow compile-time if and compile-time while loops, then thetransformation of example 15.1b to metaprogramming would be straightforward. The MASM assembly language has full metaprogramming features, including the ability to define function names and variable names from string functions. A metaprogramming implementation analogous to example 15.1b and d in assembly language is provided as an example in the "Macro loops" chapter in manual 2: "Optimizing subroutines in assembly language"."

Right now we can (awkwardly) implement conditionals using template specialization and loops using recursive template instantiation.I understand the proposed static_if facility is intended to avoid the awkwardness in the case of the compile-time if statements.Would it be possible for the next revision of the standard to get an analogous (as described above) compile-time loops extension?