title: c++ auto type signed to/from unsigned conversion
body: <p>I want to write a function that performs bit-wise operations on a parameter that is <code>auto</code> type.</p>
  
  <ul>
  <li>The type passed in might be <code>unsigned int</code> or <code>int</code> type (with differing widths).</li>
  <li>I only want to perform bit-wise operations on <code>unsigned</code> types.</li>
  </ul>
  
  <p>I need an operator that returns the <code>unsigned</code> version of the original data type. In the function example below the "operator" <code>unsigned_type</code> would give me the data type that <code>value</code> has but insure it is unsigned.</p>
  
  <ul>
  <li><code>int</code> -> <code>unsigned int</code></li>
  <li><code>int16_t</code> -> <code>uint16_t</code></li>
  <li><code>uint16_t</code> -> <code>uint16_t</code></li>
  </ul>
  
  <p>Function example:</p>
  
  <pre><code>auto bit_shifting_and_mask(auto value) -&gt; decltype(value)
  {
      unsigned_type(value) unsigned_value = static_cast&lt;unsigned_type(value)&gt;(value);
  
      unsigned_value &gt;&gt;= 8u;       // Contrived bit manipulation
      unsigned_value &amp;= 0xABCDu;   // here ...
  
      return static_cast&lt;decltype(value)&gt;(unsigned_value);
  }
  </code></pre>
  
  <p>Is there some means to perform the operation <code>unsigned_type</code> against a data type obtained from <code>decltype</code>?</p>
  
  <p>Thanks.</p>