martinzink commented on code in PR #2213:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2213#discussion_r3550057709


##########
core-framework/common/include/utils/ParsingUtils.h:
##########
@@ -90,4 +91,22 @@ std::expected<T, std::error_code> parseEnum(const 
std::string_view input) {
   return *result;
 }
 
+template<std::floating_point T>
+std::expected<T, std::error_code> parseFloatingPoint(const std::string_view 
input) {
+  const auto trimmed_input = utils::string::trim(input);
+  T value{};
+
+  const auto [ptr, ec] = std::from_chars(trimmed_input.data(), 
trimmed_input.data() + trimmed_input.size(), value);

Review Comment:
   Unlike other parsing functions in C++ and C libraries, std::from_chars is 
locale-independent, non-allocating, and non-throwing.
   
   source: https://en.cppreference.com/cpp/utility/from_chars



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to