title: Testing the signedness of a template parameter
body: <p>I need to mask out some leading bits of an value. If the value is unsigned, I can assert (guarantee) that the some arbitrary number of leading bits are not set, that is the value is guaranteed to be limited.</p>
  
  <p>If it is signed, I need to mask out the leading bits (turning the value into some nonportable heap of bits, yes, I am aware of that :-)). I would like to save the masking operation if the value is unsigned.</p>
  
  <p>So I basically have</p>
  
  <pre><code>template&lt;typename T, some more template parameters&gt;
  class {
      unsigned transform(T value) {
          ...
          if (isSigned(T)) {
              value &amp;= mask;
          }
          ...
      }
  }
  </code></pre>
  
  <p>Is there an easy way to write an isSigned() which can be evaluated at compile time (to enable the optimizer to remove the unsigned dead code)?</p>
  
  <p>Of course I could add another template parameter...</p>