Logo
Explore Help
Sign In
OilfieldToolsNet/opm-simulators
4
0
Fork 0
You've already forked opm-simulators
mirror of https://github.com/OPM/opm-simulators.git synced 2025-02-25 18:55:30 -06:00
Code Issues Packages Projects Releases Wiki Activity
Files
9300e4819a931d7ab75f03a68c2eb6fb84bfc4d7
opm-simulators/cmake/test/testFloatFromChars.cpp

12 lines
251 B
C++
Raw Normal View History

Don't Require Floating Point from_chars() Function This commit broadens the scope of commit 2ad332e0b (PR #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).
2024-08-15 09:55:50 +02:00
// 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);
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 32ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API