MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / parse_nonnegative_int

Function parse_nonnegative_int

extlibs/fmt/include/fmt/format.h:1987–2005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1985// that the range is non-empty and the first character is a digit.
1986template <typename Char, typename ErrorHandler>
1987FMT_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
2007template <typename Context> class custom_formatter {
2008 private:

Callers 5

parse_arg_idFunction · 0.85
parse_widthFunction · 0.85
parse_precisionFunction · 0.85
parse_headerMethod · 0.85
formatMethod · 0.85

Calls 1

on_errorMethod · 0.45

Tested by

no test coverage detected