forked from OPM/opm-models
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't Require Floating Point from_chars() Function
This commit broadens the scope of commit 2ad332e (PR OPM#922) to apply to all compilers/libraries, not just Clang/libc++, which do not have support for floating-point types in std::from_chars(). While hopefully a transient situation, this enables building the parameter system with GCC versions prior to GCC 11. We expect to require version 11 in the not too distant future, though. At that point we should revert this commit. We use a configure-time feature test of the compiler (CMake command 'try_compile') to detect whether or not the compiler supports floating-point overloads of std::from_chars() and emit the result to config.h as the new preprocessor symbol HAVE_FLOATING_POINT_FROM_CHARS We use std::strtod() as the fall-back alternative for floating point conversion if this symbol is defined to false (zero).
- Loading branch information
Showing
4 changed files
with
34 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// CMake feature test for floating-point std::from_chars() support | ||
|
||
#include <charconv> | ||
#include <string_view> | ||
|
||
int main() | ||
{ | ||
const auto s = std::string_view { "2.71828" }; | ||
auto e = 0.0; | ||
std::from_chars(s.data(), s.data() + s.size(), e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters