Note that there are some explanatory texts on larger screens.

plurals
  1. POForcing variadic template member function instantiation in class
    primarykey
    data
    text
    <p>I have a class which has a variadic member function:</p> <pre><code>class class_name { template&lt;ArgTypes.. args&gt; some_return_type memberMethod(ArgTypes... args) { //stuff... } } </code></pre> <p>I need to force instantiation of this method <strong>inside the class definition block</strong>. I loose the method name outside of the class definition block because the class is generated by a bunch of macros.</p> <p>I try to force the instantiation by copying a pointer to a specialised member function (pseudo code):</p> <pre><code>template&lt;typename Self, typename RetType, typename... ArgTypes&gt; struct force_instantation_imlp&lt;Self, RetType, type_placeholder, type_placeholder&lt;ArgTypes...&gt;&gt; { force_instantation_imlp() { using instate = RetType (Self::*)(ArgTypes...); instate force = &amp;Self::memberMethod&lt;ArgTypes...&gt;; } }; class class_name { template&lt;ArgTypes.. args&gt; some_return_type memberMethod(ArgTypes... args) { //stuff... } force_instantation_imlp&lt;class_name, some_return_type, rest_of_types_deduced_from_context&gt; force_virtual_instantation; } </code></pre> <p><code>type_placeholder</code> is just a helper template to "freeze" parameter pack.</p> <p>This unfortunately gives me a compile error </p> <pre><code>error: expected primary-expression before ‘...’ token instate force = &amp;Self::memberMethod&lt;ArgTypes...&gt;; </code></pre> <p>I guess that this error results from teh fact that the member function is a variadic template.</p> <p>Is there any way to force variadic template member function instantiation inside the class definition block?</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.
 

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