MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / as_integer_helper

Function as_integer_helper

system/lib/libcxx/src/string.cpp:107–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105
106template <typename V, typename S, typename F>
107inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
108 typename S::value_type* ptr = nullptr;
109 const typename S::value_type* const p = str.c_str();
110 __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
111 errno = 0;
112 V r = f(p, &ptr, base);
113 swap(errno, errno_save);
114 if (errno_save == ERANGE)
115 throw_from_string_out_of_range(func);
116 if (ptr == p)
117 throw_from_string_invalid_arg(func);
118 if (idx)
119 *idx = static_cast<size_t>(ptr - p);
120 return r;
121}
122
123template <typename V, typename S>
124inline V as_integer(const string& func, const S& s, size_t* idx, int base);

Callers

nothing calls this directly

Calls 5

fFunction · 0.50
swapFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected