title: How can auto distinguish short from long at compile time?
body: <p>I'm excited to use <code>auto</code> variables in my C++ programs. I know variables declared with <code>auto</code> use template rules to deduce variable types, but I'm confused as to how that works for numeric types. Suppose I have:</p>
  
  <pre><code>auto foo = 12;
  </code></pre>
  
  <p>The type for <code>foo</code> could reasonably be <code>int</code> or even <code>unsigned char</code>.  But suppose that later in my program I do some math and assign foo a value of 4 billion. At that point, I would want <code>foo</code> to become type <code>unsigned int</code> or perhaps <code>long</code>.</p>
  
  <p>How can compilers anticipate values that will be assigned later in the program?</p>