title: Template specialization for multiple types
body: <p>Title is a little ambiguous.</p>
  
  <p>Lets say I have a template defined as:</p>
  
  <pre><code>template &lt; typename T &gt;
  void foo ( int x ) ;
  template &lt;&gt;
  void foo&lt;char&gt; ( int x ) ;
  template &lt;&gt;
  void foo&lt;unsigned char&gt; ( int x ) ;
  template &lt;&gt;
  void foo&lt;short&gt; ( int x ) ;
  ...
  </code></pre>
  
  <p>Internally both <code>foo&lt;signed&gt;()</code> and <code>foo&lt;unsigned&gt;()</code> do exactly the same thing. The only requirement is that <code>T</code> be an 8bit type.</p>
  
  <p>I could do this by creating another template to type define a standard type based on size.</p>
  
  <pre><code>template &lt; typename T, size_t N = sizeof( T ) &gt; struct remap ;
  template &lt; typename T, size_t &gt; struct remap&lt; 1 &gt;
  {
      typedef unsigned char value;
  }
  ...
  </code></pre>
  
  <p>Note, function templates cannot have default parameters. This solution only relocates the problem to another template and also introduces a problem if somebody tried passing a struct type as a parameter.</p>
  
  <p>What is the most elegant way to solve this without repeating those function declarations?</p>
  
  <p>This is not a C++11 question.</p>