From e0e686fd99b499c846eacbaea8fdf4f6726db2f2 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Fri, 2 Feb 2024 21:35:18 -0600 Subject: [PATCH] Add fp overload for MacOS functionality --- dCommon/GeneralUtils.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index 03a06283..ac5b3d16 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -163,19 +163,24 @@ namespace GeneralUtils { return isParsed ? static_cast(result) : std::optional{}; } +#ifdef __APPLE__ + /** * For floating-point values: Parses a C-style char range (string) and returns an optional variable depending on the result + * Note that this function is only included for MacOS, as from_chars will fufill its purpose otherwise * @param str The pointer to the start of the char range (string) - * @param strEnd The pointer to the end of the char range (string), defaults to NULL + * @param strEnd The pointer to the end of the char range (string), defaults to NULL but is unused * @returns An std::optional containing the desired value if it exists in the string */ - /*template + template [[nodiscard]] std::optional TryParse(const char* const str, const char* const strEnd = NULL) noexcept try { return std::make_optional(std::stold(str)); } catch (...) { return std::nullopt; - }*/ + } + +#endif /** * The TryParse overload for std::string