Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>please look at boost tuple implementation (solves a similar problem). The main idea is that you can specify a maximum number of template arguments for your FollAll&lt;...>() method, and provide default types for most of them. Here is a sketch of what I have in mind</p> <pre><code>#include &lt;boost/type_traits/is_same.hpp&gt; #include &lt;boost/mpl/eval_if.hpp&gt; #include &lt;boost/mpl/vector.hpp&gt; #include &lt;boost/mpl/push_back.hpp&gt; using boost::is_same; using boost::mpl::eval_if; using boost::mpl::vector; using boost::mpl::push_back; struct EmptyType { }; struct A { template&lt;typename arg1, typename arg2=EmptyType, typename arg3=EmptyType, ..., typename argN=EmptyType&gt; void FooAll() { // reconstruct the type vector for easy manipulation later // Bolierplate code! typedef vector&lt;arg&gt; vector_arg1; typedef typename eval_if&lt;is_same&lt;arg2, EmptyType&gt;, vector_arg1, push_back&lt;vector_arg1, arg2&gt; &gt;::type vector_arg2; typedef typename eval_if&lt;is_same&lt;arg3, EmptyType&gt;, vector_arg2, push_back&lt;vector_arg2, arg3&gt; &gt;::type vector_arg3; //... rest of arguments typedef typename eval_if&lt;is_same&lt;argN, EmptyType&gt;, vector_arg(N-1), push_back&lt;vector_arg(N-1), argN&gt; &gt;::type vector_argN; // now you can manipulate the reconstructed type vector Do_some_internal_stuff&lt;vector_argN&gt;::apply(); } } </code></pre> <p>If you want to go 'high-tech' you can try out a C++11 standard feature named <a href="/http://en.wikipedia.org/wiki/Variadic_template" title="Variadic Templatesquot;">Variadic Templates</a>. But be sure that compilers you are targeting, already support this feature.</p> <p>Best Regards, Marcin</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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