Is there a way to do the following directly using stream operators?
uint8_t actual;
uint32_t temporary;
std::cin >> std::dec >> temporary;
if (temporary > UINT8_MAX) {
// error
}
actual = static_cast<uint8_t>(temporary);
In particular, I would like to parse a sufficiently small decimal number into a uint8_t without resorting to a larger temporary variable.