Less hackish implementation for integer_range.