-
-
Save ilpropheta/43e63f692540faaaed46a9ff14935d0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string_view parse_int(string_view sv, int& i) | |
{ | |
if(sv.empty() || ((!isdigit(sv[0])) && (sv[0] != '-') && (sv[0] != '+'))) | |
// handle error | |
char* endPtr = nullptr; | |
i = strtol(sv.data(), &endPtr, 10); | |
if (*endPtr != 0) // assumption | |
// handle error | |
return sv.substr(endPtr-sv.begin()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment