Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If <code>CSimpleTable</code> is the base class, you need to qualify your call with that base class name or alternatively with <code>this</code>. But since both of these depend on the template parameters, the compiler cannot lookup what the name <code>BinarySearch</code> means. It could be a static integer constant, which you compare against something else, or it could be a template that you put arguments enclosed in <code>&lt;...&gt;</code> for. You need to tell the compiler about the latter</p> <pre><code>/* the "::template" means: 'the name that follows is a template' */ return CSimpleTable&lt;CSimpleKey&lt;T&gt; &gt;::template BinarySearch&lt;uint32, CSimpleKey&lt;T&gt; &gt;(key); </code></pre> <p>Or with <code>this</code></p> <pre><code>return this-&gt;template BinarySearch&lt;uint32, CSimpleKey&lt;T&gt; &gt;(key); </code></pre> <p>The reason for the qualification is that the compiler does not look for unqualified names in base classes that depend on template parameters (in your case the parameter is <code>T</code>), since the binding of the name would depend on whether the base class has such a name or not, which is considered unfortunate. For a plain name like <code>BinarySearch</code>, there is in addition no indication that this name depends on a template parameter, thus the Standard requires compilers not to delay lookup of the name until instantiation. So the name, even if lookup in dependent bases would be allowed on instantiation (which isn't), couldn't be found anyway. </p> <p>You have to explicitly tell the compiler to look in the enclosing class by qualifying it, in which event the compiler will include dependent base classes during lookup when instantiating. Prefixing with <code>this</code> or the class name will also make the name <em>dependent</em>, thus delaying lookup of it until instantiation. These two facts are required for it to work. </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