I'm excited to use auto variables in my C++ programs. I know variables declared with auto use template rules to deduce variable types, but I'm confused as to how that works for numeric types. Suppose I have:
auto foo = 12;
The type for foo could reasonably be int or even unsigned char. 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 foo to become type unsigned int or perhaps long.
How can compilers anticipate values that will be assigned later in the program?