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

Function as_string

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

Source from the content-addressed store, hash-verified

291
292template <typename S, typename P, typename V >
293inline S as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) {
294 typedef typename S::size_type size_type;
295 size_type available = s.size();
296 while (true) {
297 int status = sprintf_like(&s[0], available + 1, fmt, a);
298 if (status >= 0) {
299 size_type used = static_cast<size_type>(status);
300 if (used <= available) {
301 s.resize(used);
302 break;
303 }
304 available = used; // Assume this is advice of how much space we need.
305 } else
306 available = available * 2 + 1;
307 s.resize(available);
308 }
309 return s;
310}
311
312template <class S>
313struct initial_string;

Callers 2

to_stringFunction · 0.85
to_wstringFunction · 0.85

Calls 2

sizeMethod · 0.65
resizeMethod · 0.65

Tested by

no test coverage detected