About The Awe For Templates
Using the C++ template language like a full programming language is very much like using the BrainFuck language:
You can do it, but there are usually much, much better ways of doing compile-time code generation:
A) Use a proper macro language such as M4. I venture to say that in 99% of cases that is all you need. Expand the code onto disk and have proper error messages that can be used by your IDE to jump right to the faulty parametric code. Massive, successful and well-performing systems like CATIA use this approach instead of templates.
B) Use a plain C++ program to generate some other C++ code. Call that generator from a make file like you call the m4 macro processor. That spares you to dive into Brainfuck/teamplate language.
Generic code and code generation are not mystical things, they are actually quite straighforward as soon as you remove the C++ Brainfuck variant from the whole story. There is absolutely no need for weird and difficult-to-decipher error messages of you use the approach from above.
But hell yeah, you need to question the holy gods (who are as jealous as that other jealous middle east god) of the C++ standards committee.