MCPcopy Create free account
hub / github.com/audacity/audacity / IntFromChars

Function IntFromChars

libraries/lib-string-utils/FromChars.cpp:125–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124template <typename ResultType>
125FromCharsResult
126IntFromChars(const char* buffer, const char* last, ResultType& value) noexcept
127{
128 const char* origin = buffer;
129
130 if (buffer >= last)
131 return { buffer, std::errc::invalid_argument };
132
133 const bool isNegative = *buffer == '-';
134
135 if (isNegative)
136 {
137 if constexpr (std::is_signed_v<ResultType>)
138 ++buffer;
139 else
140 return { origin, std::errc::invalid_argument };
141 }
142
143 const auto fastStringResult =
144 FastStringToInt(buffer, last, value, isNegative);
145
146 if (fastStringResult.ec == std::errc::invalid_argument)
147 return { origin, std::errc::invalid_argument };
148
149 return fastStringResult;
150}
151} // namespace
152
153FromCharsResult FromChars(const char* buffer, const char* last, float& value) noexcept

Callers 1

FromCharsFunction · 0.85

Calls 1

FastStringToIntFunction · 0.85

Tested by

no test coverage detected