A programming technique in which computer programs have the ability to treat other programs as their data is known as metaprogramming. This means that a program can be designed to read, generate, analyze, or transform other programs, and even modify itself while running. One kind of metaprogramming is a compiler, which takes a text format program as an input language (C, Fortran, Java, and so on) and produces another binary machine code format program in an output language.
C++ template metaprogramming (TMP) means producing metaprograms in C++ using templates. It has two components – a template must be defined, and a defined template must be instantiated. TMP is Turing-complete, which means it has the capability to compute anything that is computable, at least in principle. Also, because variables are all immutable (variables are constants...