C++ does not support run-time resolution of template type arguments. To circumvent this restriction, we can instantiate a template for all possible combinations of type arguments at compile time and then select the proper instance at run time by evaluation of some provided conditions. However, for templates with multiple type parameters such a solution may easily result in a branching code bloat. We present a template metaprogramming algorithm called for-id that allows the user to select the proper template instance at run time with theoretical minimum sustained complexity of the branching code. © 2012 Springer-Verlag.
Publication Source (Journal or Book title)
Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Langr, D., Tvrdík, P., Dytrych, T., & Draayer, J. (2012). Fake run-time selection of template arguments in C++. Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 7304 LNCS, 140-154. https://doi.org/10.1007/978-3-642-30561-0_11