title: template specialization according to sizeof type
body: <p>I would like to provide a templated function, that varies its implementation (->specialization) according to the sizeof the template type.</p>
  
  <p>Something similar to this (omitted typecasts), but without the if/elseif:</p>
  
  <pre><code>template&lt;class T&gt;
  T byteswap(T &amp; swapIt)
  {
      if(sizeof(T) == 2)
      {
          return _byteswap_ushort (swapIt);
      }
      else if(sizeof(T) == 4)
      {
          return _byteswap_ulong(swapIt);
      }
      else if(sizeof(T) == 8)
      {
          return _byteswap_uint64(swapIt);
      }
              throw std::exception();
  }
  </code></pre>
  
  <p>I know there are many roads to reach my goal, but since I try to learn about <code>SFINAE</code> and <code>type traits</code> I'm particularly interested in solutions using those techniques to decide at compile time which specialization to choose and which calls are not admitted.  </p>
  
  <p>Perhaps implementing a class trait is_4ByteLong and using boost::enable_if...</p>
  
  <p>I have to admit, I'm stuck right now, so I thank you for any help or advice</p>