| 1985 | // that the range is non-empty and the first character is a digit. |
| 1986 | template <typename Char, typename ErrorHandler> |
| 1987 | FMT_CONSTEXPR int parse_nonnegative_int(const Char*& begin, const Char* end, |
| 1988 | ErrorHandler&& eh) { |
| 1989 | FMT_ASSERT(begin != end && '0' <= *begin && *begin <= '9', ""); |
| 1990 | unsigned value = 0; |
| 1991 | // Convert to unsigned to prevent a warning. |
| 1992 | constexpr unsigned max_int = max_value<int>(); |
| 1993 | unsigned big = max_int / 10; |
| 1994 | do { |
| 1995 | // Check for overflow. |
| 1996 | if (value > big) { |
| 1997 | value = max_int + 1; |
| 1998 | break; |
| 1999 | } |
| 2000 | value = value * 10 + unsigned(*begin - '0'); |
| 2001 | ++begin; |
| 2002 | } while (begin != end && '0' <= *begin && *begin <= '9'); |
| 2003 | if (value > max_int) eh.on_error("number is too big"); |
| 2004 | return static_cast<int>(value); |
| 2005 | } |
| 2006 | |
| 2007 | template <typename Context> class custom_formatter { |
| 2008 | private: |
no test coverage detected