Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can achieve what you want by encapsulating the variadic argument pack in a tuple and later using the following two helper template structs to forward the actual variadic arguments:</p> <pre><code>template&lt;typename PackR, typename PackL&gt; struct cat; template&lt;typename ...R, typename ...L&gt; struct cat&lt;std::tuple&lt;R...&gt;, std::tuple&lt;L...&gt;&gt; { typedef std::tuple&lt;R..., L...&gt; type; }; </code></pre> <p>and</p> <pre><code>template&lt;typename Pack, template&lt;typename ...T&gt; class Receiver&gt; struct Unpack; template&lt;typename ...Args, template&lt;typename ...T&gt; class Receiver&gt; struct Unpack&lt;std::tuple&lt;Args...&gt;, Receiver&gt; { typedef Receiver&lt;Args...&gt; type; }; </code></pre> <p>your code sample would look like this:</p> <pre><code>#include &lt;set&gt; #include &lt;cstdint&gt; #include &lt;tuple&gt; template&lt;typename PackR, typename PackL&gt; struct Cat; template&lt;typename ...R, typename ...L&gt; struct Cat&lt;std::tuple&lt;R...&gt;, std::tuple&lt;L...&gt;&gt; { typedef std::tuple&lt;R..., L...&gt; type; }; template&lt;typename Pack, template&lt;typename ...T&gt; class Receiver&gt; struct Unpack; template&lt;typename ...Args, template&lt;typename ...T&gt; class Receiver&gt; struct Unpack&lt;std::tuple&lt;Args...&gt;, Receiver&gt; { typedef Receiver&lt;Args...&gt; type; }; template&lt;typename ...Args&gt; struct Forward { //typedef Args... args; // Problem here!! typedef std::tuple&lt;Args...&gt; args; // Workaround static const std::size_t size = sizeof...(Args); }; template&lt;typename S, typename T, template&lt;typename ...SArgs&gt; class SCont, template&lt;typename ...TArgs&gt; class TCont, typename SForward = Forward&lt;&gt; , typename TForward = Forward&lt;&gt;&gt; class Bimap { //typedef SCont&lt;S, typename SForward::args&gt; left_type; //typedef TCont&lt;T, typename TForward::args&gt; right_type; typedef typename Unpack&lt;typename Cat&lt;std::tuple&lt;S&gt;, typename SForward::args&gt;::type, SCont&gt;::type left_type; //Workaround typedef typename Unpack&lt;typename Cat&lt;std::tuple&lt;T&gt;, typename TForward::args&gt;::type, TCont&gt;::type right_type; //Workaround template&lt;typename LeftIt, typename RightIt&gt; struct Relation; // to be implemented typedef Relation&lt;typename left_type::const_iterator, typename right_type::const_iterator&gt; relation_type; }; int main() { Bimap&lt;int, int, std::set, std::set, Forward&lt;std::less&lt;int&gt;&gt; , Forward&lt;std::greater&lt;int&gt;&gt;&gt; x; } </code></pre> <p>which compiles just fine under gcc 4.6.0</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload