title: Print template typename at compile time
body: <p>When creating a template function in C++ is there a simple way to have the typename of the template represented as a string?  I have a simple test case to show what I'm trying to do (note the code shown does not compile):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  template &lt;typename type&gt;
  type print(type *addr) 
  {
    printf("type is: %s",type);
  }
  
  int main()
  {
    int a;
    print(&amp;a);
  }
  
  // Would like to print something like:
  // type is: int
  </code></pre>
  
  <p>I think that the typename should be available at compile time when the function is instantiated, but I'm not that familiar with templates and I haven't seen a way to get the typename as a string.  </p>
  
  <p>The reason that I want to do this is for some printf type debugging.  I have multiple threads running and stepping through with gdb changes the program behavior.  So for some things I want to dump information about which functions were executing.  It's not too important so if the solution is overly complex I would skip adding this information to my logging function.  But if there was a simple way to do this it would be useful information to have.</p>