static inline T doConvertToIntType(const String::buf_t& m_buf, const char* type, FP fp, int base) { if (m_buf) { char* endptr(0); errno = 0; // errno is thread local FPRT v = fp(m_buf->data(), &endptr, base); T rv = static_cast<T>(v); if (*endptr != '\0' || errno == ERANGE || FPRT(rv) != v) { throwStringConversion(m_buf, type); } return rv; } else { throwStringConversion("", type); } return T(); // to make compiler happy }
static inline T doConvertToIntType(const String::buf_t& m_buf, const char* type, FP fp, int base) { // the error detecting code below won't detect an empty string, so // we have to check for it explicitly. if (m_buf && m_buf->length() > 0) { char* endptr(0); errno = 0; // errno is thread local FPRT v = fp(m_buf->data(), &endptr, base); T rv = static_cast<T>(v); if (*endptr != '\0' || errno == ERANGE || FPRT(rv) != v) { throwStringConversion(m_buf, type); } return rv; } else { throwStringConversion("", type); } return T(); // to make compiler happy }