mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-24 16:30:02 -06:00
Merge pull request #922 from atgeirr/from_char-workaround
Add workaround for libc++ incomplete from_chars().
This commit is contained in:
commit
8d382f7dcb
@ -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