Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>GCC is right in this case, and Visual Studio mistakenly accepts a malformed program. Have a look at the section on <a href="http://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html" rel="noreferrer">Name lookup</a> in the GCC manual. Paraphrasing:</p> <blockquote> <p>[T]he call to [<code>get()</code>] is not dependent on template arguments (there are no arguments that depend on the type T, and it is also not otherwise specified that the call should be in a [template-]dependent context). <strong>Thus a global declaration of such a function must be available, since the one in the base class is not visible until instantiation time.</strong></p> </blockquote> <p>You can get around this in either of three ways:</p> <ul> <li>The declarations you are already using.</li> <li><code>Base&lt;T&gt;::get()</code></li> <li><code>this-&gt;get()</code></li> </ul> <p>(There is also a fourth way, if you want to succumb to the Dark Side:</p> <blockquote> <p>Using the <code>-fpermissive</code> flag will also let the compiler accept the code, by marking all function calls for which no declaration is visible at the time of definition of the template for later lookup at instantiation time, as if it were a dependent call. We do not recommend using <code>-fpermissive</code> to work around invalid code, and it will also only catch cases where functions in base classes are called, not where variables in base classes are used (as in the example above).</p> </blockquote> <p>But I would recommend against that, both for the reason mentioned in the manual, and for the reason that your code will still be invalid C++.)</p>
    singulars
    1. This table or related slice is empty.
    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.
    3. 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