Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are trying to pass <code>SmartPtr</code> as a template <em>type</em> argument to <code>ThreadingModel</code>. <code>SmartPtr</code> however is a template, not a concrete type, and the <a href="http://books.google.de/books?id=EotSAwuBkJoC&amp;pg=PA126&amp;lpg=PA126&amp;dq=c%2B%2B+injected+class-name&amp;source=bl&amp;ots=iwOYJ9_hgh&amp;sig=7-6UMoMHZctldpOYPvDucV4bXE8&amp;hl=de&amp;ei=YMRkTLuvEeacOLC4gKoK&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=4&amp;ved=0CCkQ6AEwAw#v=onepage&amp;q=c%2B%2B%20injected%20class-name&amp;f=false" rel="noreferrer">injected class-name</a> is not available in the inheritance list. </p> <p>Also note that you can't just use default arguments for template parameters in arbitrary positions (<em>§14.1/11</em>): </p> <blockquote> <p>If a template-parameter has a default template-argument, all subsequent template-parameters shall have a default template-argument supplied.</p> </blockquote> <p>Your code with those issues fixed:</p> <pre><code>template &lt; class T, template &lt;class&gt; class ThreadingModel, template &lt;class&gt; class CheckingPolicy = EnsureNotNull &gt; class SmartPtr : public CheckingPolicy&lt;T&gt; , public ThreadingModel&lt;SmartPtr&lt;T, ThreadingModel, CheckingPolicy&gt; &gt; // ^ .... now passing a concrete class .... ^ { T* operator-&gt;() { // the following use of SmartPtr is fine as it is the injected class-name: typename ThreadingModel&lt;SmartPtr&gt;::Lock guard(*this); // ... } }; </code></pre> <p>Note that while <em>Modern C++ Design</em> is an excellent book, it can't replace a good basic book on templates like <a href="http://www.josuttis.com/tmplbook/" rel="noreferrer">Vandevoorde/Josuttis</a>.</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