-
-
Save ilpropheta/ab72ff0d6842e418e42f11c92b9d60f2 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
auto mult = number[0] == '-' ? -1 : 1; | |
auto realBegin = mult > 0 ? begin(number) : next(begin(number)); | |
auto toInt = mult * accumulate(realBegin, end(number), 0, [](int curr, char nxt){ | |
return curr * 10 + nxt - '0'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment