Personally, I'd reduce it even further


while (num.size() == 1 && num[0] >= '1' && num[0] <= '3')

True, this takes slightly more typing, but it offers other advantages such readability...