Fake Run-Time Selection of Template Arguments in C++
Daniel Langr, Pavel Tvrd\'ik, Tom\'a\v{s} Dytrych, Jerry P. Draayer

TL;DR
This paper introduces a template metaprogramming algorithm called for_id that enables run-time selection of C++ template arguments efficiently, reducing code bloat and complexity.
Contribution
The paper presents a novel algorithm for run-time template argument selection in C++, minimizing branching complexity and improving efficiency.
Findings
The for_id algorithm reduces code bloat in run-time template selection.
It maintains minimal branching complexity for multiple template parameters.
The method improves efficiency in C++ template metaprogramming.
Abstract
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.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
