title: Tool to detect C++ template issues
body: <p>I recently spent some time hunting down a typo in my C++ templates. g++ did not complain about the typo, so I was wondering if there is a tool which can check for this type of problem in the future? </p>
  
  <p>Here is a simplified example which demonstrates the correct compilation. I would expect a complaint about struct dummy not being defined, but it seems like the templated class goo hides that. </p>
  
  <p>foo.h:</p>
  
  <pre><code>struct smart {
      int x, y, z;
  };
  
  template&lt;typename T&gt; class goo
  {
      void barf(T* ptr){}
  };
  
  template&lt;typename T&gt; class foo 
  {
  public:
      foo(){};
  private:
      goo&lt;T&gt; x;
  };
  
  class bar: public foo&lt;struct dummy&gt;
  {
  public:
      void do_something(struct smart&amp; thing){}
  };
  </code></pre>
  
  <p>foo.cpp:</p>
  
  <pre><code>#include "foo.h"
  
  int main()
  {
      bar a;
      struct smart b;
      a.do_something(b);
      return b.x+b.y+b.z;
  }
  </code></pre>
  
  <p>Compiles successfully with g++ foo.cpp</p>