#include <sstream> bool str_to_uint64(const char* nptr, uint64_t& result) { char** endptr = '\0'; result = strtoull(nptr, endptr, 0); if (endptr != '\0') { return false; } std::stringstream ss(""); ss << result; std::string tmp = ss.str(); if (tmp.compare(nptr) != 0) { return false; } return true; }