It depends on which design template you are interested in. Some of them are similar to "Active Object" and Dispose, which at the time of compilation would be complex.
"interpreter" -> boost.ublas and blitz ++ use "expression patterns"
"bridge" pattern -> Each standard container accepts a "dispenser" argument (most of Loki are also bridge patterns)
"strategy" β STL template functions select the best implementation based on argument types
The only difference in all of these cases is that the evaluation of the template occurs when the compiler is running, and not when the executable is running. So, all you need is to slightly change your thinking: templates are a program, and the βC ++ compilerβ launches and interprets this program. The output of this template program is an object file ready for linking. In other words, the execution time of your precisley code template is when your compiler is running. C ++ templates are the full functional turing language, like lisp or XSLT.
In fact, the first metaprogram of the template in 1993 had as its output not an executable file, but a series of compiler errors that printed a sequence of fibonasias or something like that.
source share