Chain of functions for variadic template arguments <p>I am trying to design a generic, type-safe way to load interleaved data into a OpenGL VBO. My problem is now how to organize the various glVertexAttribPointer() calls. I have defined the buffer data descriptor as follows.</p> <pre><code>template &lt;typename T&gt; struct Descriptor { T vertex; }; template &lt;typename T, typename U&gt; struct Descriptor { T vertex; U normal; }; ... </code></pre> <p>This is basically now all well and simple. However, my problem is that the template functions to actually set the attributes turned out as follows.</p> <pre><code>template &lt;template &lt;class&gt; class Desc, typename T&gt; void setAttributes(const Desc&lt;T&gt;&amp; desc) { // set attributes for vertices ... glVertexAttribPointer(0, sizeof(desc.vertex), ...); } template &lt;template &lt;class, class&gt; class Desc, typename T, typename U&gt; void setAttributes(const Desc&lt;T, U&gt;&amp; desc) { // set attributes for vertices ... glVertexAttribPointer(0, sizeof(desc.vertex), ...); // set attributes for normals ... glVertexAttribPointer(1, sizeof(desc.normal), ...); } ... </code></pre> <p>Basically the problem is that I still ended up with a lot of repetition. Is there a way break these down into two template functions where one only sets vertex attributes and one sets only normals? In pseudocode something like the following.</p> <pre><code>template &lt;class Desc, class T, Args...&gt; void setAttributes(Desc desc) { setVertexAttributes(...); // somehow decide that if there are args left, call again... } template &lt;class Desc, class U, Args...&gt; void setAttributes(Desc desc) { // ...ending up here setNormalAttributes(...); } </code></pre>