title: Static polymorphism in C++
body: <pre><code>#include &lt;iostream&gt;
  
  template&lt;typename Impl&gt;
  struct renderer{
      void get(){
          static_cast&lt;Impl*&gt;(this)-&gt;get();
      }
  };
  struct open_gl : public renderer&lt;open_gl&gt;{
      void get(){
          std::cout &lt;&lt; "OpenGL" &lt;&lt; std::endl;
      }
  };
  struct direct_draw : public renderer&lt;direct_draw&gt;{
      void get(){
          std::cout &lt;&lt; "DX" &lt;&lt; std::endl;
      }
  };
  template&lt;typename T&gt;
  void print_renderer(renderer&lt;T&gt; r){
      r.get();
  }
  int main() {
      auto gl = open_gl();
      auto dx = direct_draw();
      print_renderer(gl);
      print_renderer(dx);
  }
  </code></pre>
  
  <ol>
  <li><p>Why can't I change the parameter of print_renderer to <code>void
  print_renderer(const renderer&lt;T&gt; &amp;r)</code>? 
  <code>cannot convert 'this' pointer from 'const renderer&lt;open_gl&gt;' to 'renderer&lt;open_gl&gt; &amp;'</code>
  `</p></li>
  <li><p>Why do I get a runtime error when I rename the method <code>get</code> in open_gl from
  get to get1? Shouldn't this trigger a compiler error? <code>Error = Stack overflow</code></p></li>
  </ol>
  
  <p>**Note I am using the latest MSVC</p>