title: curiously recurring template pattern and infinite recursion
body: <p>Take a look at the following simple curiously recurring template pattern (CRTP) example:</p>
  
  <pre><code>template&lt;class Derived&gt;
  struct base
  {
      void foo() {
          static_cast&lt;Derived*&gt;(this)-&gt;foo();
      }
  };
  
  struct derived
      : public base&lt;derived&gt;
  {};
  </code></pre>
  
  <p>Since <code>derived</code> has no member function <code>foo</code> other than the one derived from <code>base</code>, the invocation <code>derived{}.foo()</code> yields an infinite recursion. Can we modify the definition of <code>base::foo</code> such that <code>static_cast&lt;Derived*&gt;(this)-&gt;foo()</code> is only invoked when there is a <code>Derived::foo</code>?</p>
  
  <p><strong>EDIT</strong>: The reason why I'm asking is that the <code>foo</code> in my actual application has a template argument. And since a template method cannot be virtual, CRTP seems to be the only workaround.</p>