diff --git a/opm/models/utils/parametersystem.hh b/opm/models/utils/parametersystem.hh index 9e49f7ee0..19b2608f9 100644 --- a/opm/models/utils/parametersystem.hh +++ b/opm/models/utils/parametersystem.hh @@ -41,8 +41,8 @@ #include #include -#include #include +#include #include #include #include @@ -916,6 +916,7 @@ auto Get(bool errorIfNotRegistered) const char* const>, std::string, std::remove_const_t>; ParamType defaultValue = Param::value; + const std::string& defVal = MetaData::mutableRegistry()[paramName].compileTimeValue; if constexpr (std::is_same_v) { defaultValue = defVal; @@ -928,19 +929,13 @@ auto Get(bool errorIfNotRegistered) defaultValue = std::strtold(defVal.data(), nullptr); } #endif +#if !HAVE_FLOATING_POINT_FROM_CHARS + else if constexpr (std::is_floating_point_v) { + defaultValue = std::strtod(defVal.c_str(), nullptr); + } +#endif // !HAVE_FLOATING_POINT_FROM_CHARS else { -#ifdef _LIBCPP_VERSION // If this macro is defined, clang's libc++ is used - // For floating point types, libc++ (the llvm/clang library implementation) - // does not yet (as of clang 15) offer an implementation of std::from_chars(). - if constexpr (std::is_integral_v) { - std::from_chars(defVal.data(), defVal.data() + defVal.size(), defaultValue); - } else { - // Floating point workaround. - defaultValue = std::strtod(defVal.c_str(), nullptr); - } -#else std::from_chars(defVal.data(), defVal.data() + defVal.size(), defaultValue); -#endif } // prefix the parameter name by the model's GroupName. E.g. If