MCPcopy Create free account
hub / github.com/ceph/ceph / parse

Function parse

src/common/strtol.h:41–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39// Sadly GCC < 11 is missing the floating point versions.
40template<typename T>
41auto parse(std::string_view s, int base = 10)
42 -> std::enable_if_t<std::is_integral_v<T>, std::optional<T>>
43{
44 T t;
45 auto r = std::from_chars(s.data(), s.data() + s.size(), t, base);
46 if ((r.ec != std::errc{}) || (r.ptr != s.data() + s.size())) {
47 return std::nullopt;
48 }
49 return t;
50}
51
52// As above, but succeed on trailing characters and trim the supplied
53// string_view to remove the parsed number. Set the supplied

Callers 15

argparse_withargsFunction · 0.50
initMethod · 0.50
initMethod · 0.50
parseMethod · 0.50
parseMethod · 0.50
parse_kmlMethod · 0.50
initMethod · 0.50
initMethod · 0.50
parseMethod · 0.50
initMethod · 0.50
parseMethod · 0.50

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by 2

TESTFunction · 0.40
TESTFunction · 0.40