Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>(Repeating from my comments to the OP.)</p> <p>The actual problem in the line <code>instate force = &amp;Self::memberMethod&lt;ArgTypes...&gt;;</code> is a missing <code>template</code> keyword:</p> <pre><code>instate force = &amp;Self::template memberMethod&lt;ArgTypes...&gt;; </code></pre> <p>See, e.g. <a href="https://stackoverflow.com/q/610245/420683">Where and why do I have to put the “template” and “typename” keywords?</a></p> <p>Actually, the explicit template arguments are not necessary here [over.over]/1:</p> <blockquote> <p>A use of an overloaded function name without arguments is resolved in certain contexts to [...] a pointer to member function for a specific function from the overload set. A function template name is considered to name a set of overloaded functions in such contexts. The function selected is the one whose type is identical to the function type of the target type required in the context.</p> </blockquote> <p>i.e., because <code>instate</code> defines the function type, the compiler is able to determine which overload (<em>here:</em> template specialization) to choose for the name <code>Self::memberMethod</code>.</p> <hr> <p>There might be easier solutions to force instantiation of a function template, even inside the class definition. One that comes to my mind is to use a private <code>typedef</code> like <code>using dummy = integral_constant&lt;instate, &amp;Self::memberMethod&gt;;</code> (or a <code>static constexpr instate dummy = &amp;Self::memberMethod;</code>).</p> <p><sub>I'm quite, but not 100 % sure the <code>typedef</code> forces the instantiation of the member function template. The function template is instantiated when a definition of that function is required, and the ODR suggests this is the case here: <em>"A function whose name appears as a potentially-evaluated expression is odr-used if it is the unique lookup result or the selected member of a set of overloaded functions"</em> and <em>"Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program"</em></sub></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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