mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-22 09:16:27 -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/classname.hh>
|
||||||
#include <dune/common/parametertree.hh>
|
#include <dune/common/parametertree.hh>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -924,7 +925,18 @@ auto Get(bool errorIfNotRegistered)
|
|||||||
defaultValue = defVal == "1";
|
defaultValue = defVal == "1";
|
||||||
}
|
}
|
||||||
else {
|
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);
|
std::from_chars(defVal.data(), defVal.data() + defVal.size(), defaultValue);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// prefix the parameter name by the model's GroupName. E.g. If
|
// prefix the parameter name by the model's GroupName. E.g. If
|
||||||
|
Loading…
Reference in New Issue
Block a user