mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-25 18:50:19 -06:00
Add workaround from libc++ incomplete from_chars().
Float version not included in current version (15).
This commit is contained in:
parent
1a2cfa7a26
commit
c1e2a3a9b3
@ -41,6 +41,7 @@
|
||||
#include <dune/common/classname.hh>
|
||||
#include <dune/common/parametertree.hh>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <charconv>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@ -924,7 +925,18 @@ auto Get(bool errorIfNotRegistered)
|
||||
defaultValue = defVal == "1";
|
||||
}
|
||||
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<ParamType>) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user