MCPcopy Create free account
hub / github.com/averne/Fizeau / atoi

Function atoi

common/src/config_parse.cpp:25–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25constexpr int atoi(std::string_view s) {
26 int mult = 1, res = 0;
27 switch (s.front()) {
28 case '-':
29 mult = -1;
30 case '+':
31 s = substr(s, 1);
32 break;
33 }
34
35 for (auto c: s)
36 res = res * 10 + ctoi(c);
37
38 return mult * res;
39}
40
41static_assert(atoi("0") == 0);
42static_assert(atoi("+10") == 10);

Callers 3

input_intFunction · 0.85
config_parse.cppFile · 0.85
ini_handlerMethod · 0.85

Calls 2

substrFunction · 0.85
ctoiFunction · 0.85

Tested by

no test coverage detected