title: C++ passing a const pointer by const reference
body: <p>Hmm a strange one in VC2012 I can't seem to work out the syntax for passing a const pointer by const reference into a function of a templated class whose template argument is a non const pointer ie:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct Foo
  {
      void Add( const T&amp; Bar ) { printf(Bar); }
  };
  
  void main()
  {
  Foo&lt;char*&gt; foo;
  const char* name = "FooBar"; 
  foo.Add(name);                 // Causes error
  }
  </code></pre>
  
  <p>So I've simplified my problem here but basically I want the argument to 'Add' to have a const T ie const char*.  I've tried:</p>
  
  <pre><code>void Add( const (const T)&amp; Bar ); 
  
  typedef const T ConstT;
  void Add( const (ConstT)&amp; Bar );  
  
  void Add( const typename std::add_const&lt;T&gt;::type&amp; Bar ); 
  </code></pre>
  
  <p>None of which work.  The exact error I'm getting is:</p>
  
  <pre><code>error C2664: 'Foo&lt;T&gt;::Add' : cannot convert parameter 1 from 'const char *' to 'char *const &amp;'
            with
            [
                T=char *
            ]
            Conversion loses qualifiers 
  </code></pre>
  
  <p>which I can see is correct but how do I solve it without const casting 'name' to be non const.</p>