title: Specialized C++ template method never called
body: <p>And another template specialization problem, which I can't resolve:</p>
  
  <p>terminallog.hh</p>
  
  <pre><code>//stripped code
  
  class Terminallog {
  public:
  
      Terminallog();
      Terminallog(int);
      virtual ~Terminallog();
  
      template &lt;class T&gt;
      Terminallog &amp; operator&lt;&lt;(const T &amp;v);
      template &lt;class T&gt;
      Terminallog &amp; operator&lt;&lt;(const std::vector&lt;T&gt; &amp;v);
      template &lt;class T&gt;
      Terminallog &amp; operator&lt;&lt;(const T v[]);
      Terminallog &amp; operator&lt;&lt;(const char v[]);
  
      //stripped code 
  };
  </code></pre>
  
  <p>terminallog.hh continued (edited thanks to comment)</p>
  
  <pre><code>//stripped code 
  
  template &lt;class T&gt;
  Terminallog &amp;Terminallog::operator&lt;&lt;(const T &amp;v) {
      std::cout &lt;&lt; std::endl;
      this-&gt;indent();
      std::cout &lt;&lt; v;
      return *this;
  }
  
  template &lt;class T&gt;
  Terminallog &amp;Terminallog::operator&lt;&lt;(const std::vector&lt;T&gt; &amp;v) {
      for (unsigned int i = 0; i &lt; v.size(); i++) {
          std::cout &lt;&lt; std::endl;
          this-&gt;indent();
          std::cout &lt;&lt; "Element " &lt;&lt; i &lt;&lt; ": " &lt;&lt; v.at(i);
      }
      return *this;
  }
  
  template &lt;class T&gt;
  Terminallog &amp;Terminallog::operator&lt;&lt;(const T v[]) {
      unsigned int elements = sizeof (v) / sizeof (v[0]);
      for (unsigned int i = 0; i &lt; elements; i++) {
          std::cout &lt;&lt; std::endl;
          this-&gt;indent();
          std::cout &lt;&lt; "Element " &lt;&lt; i &lt;&lt; ": " &lt;&lt; v[i];
      }
      return *this;
  }
  
  inline
  Terminallog &amp;Terminallog::operator&lt;&lt;(const char v[]) {
      std::cout &lt;&lt; std::endl;
      this-&gt;indent();
      std::cout &lt;&lt; v;
      return *this;
  }
  
  //stripped code 
  </code></pre>
  
  <p>This compiles just fine, no errors. However when I try to do something like:</p>
  
  <pre><code>Terminallog clog(3);
  int test[] = {5,6,7,8};
  clog &lt;&lt; test;
  </code></pre>
  
  <p>it always prints me the pointer-address the of the array. In other words the specialized template </p>
  
  <pre><code>Terminallog &amp; operator&lt;&lt;(const T v[]);
  </code></pre>
  
  <p>is never called. I also verified this with an additional cout. No matter what I try the program is always calling </p>
  
  <pre><code>Terminallog &amp; operator&lt;&lt;(const T &amp;v);
  </code></pre>
  
  <p>and not the specialization. Obviously there has to be an error in my code, however I can't find it.</p>