original codes are from here: https://github.com/twitter/twemcache/blob/master/src/mc_util.c ``` cpp bool mc_strtoll(const char *str, int64_t *out) { char *endptr; long long ll; errno = 0; *out = 0LL; ll = std::strtoll(str, &endptr, 10); if (errno == ERANGE) { return false; } #if 0 // bug: if str is "123 abc" if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = ll; return true; } #endif std::string s(endptr); if (std::all_of(s.begin(), s.end(), [](unsigned char c) { return std::isspace(c); }) || *endptr == '\0' && endptr != str) { *out = ll; return true; } return false; } ```
original codes are from here: https://github.com/twitter/twemcache/blob/master/src/mc_util.c