MCPcopy Create free account
hub / github.com/ccache/ccache / parse_double

Function parse_double

src/ccache/util/string.cpp:297–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297tl::expected<double, std::string>
298parse_double(const std::string& value)
299{
300 size_t end;
301 double result;
302 bool failed = false;
303 try {
304 result = std::stod(value, &end);
305 } catch (const std::exception&) {
306 failed = true;
307 }
308
309 if (failed || end != value.size()) {
310 return tl::unexpected(FMT("invalid floating point: \"{}\"", value));
311 } else {
312 return result;
313 }
314}
315
316tl::expected<std::chrono::milliseconds, std::string>
317parse_duration(std::string_view duration)

Callers 2

parse_shardsFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected