diff options
author | B. Stack <bgstack15@gmail.com> | 2021-05-10 08:05:45 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2021-05-10 08:05:45 -0400 |
commit | 0d0f8635218a2893fcd00385019089253474f634 (patch) | |
tree | 9261c60b81eb28e068f0f2f44fd8e60214462b2a /zen/legacy_compiler.cpp | |
parent | Merge branch '11.9' into 'master' (diff) | |
download | FreeFileSync-0d0f8635218a2893fcd00385019089253474f634.tar.gz FreeFileSync-0d0f8635218a2893fcd00385019089253474f634.tar.bz2 FreeFileSync-0d0f8635218a2893fcd00385019089253474f634.zip |
add upstream 11.10
Diffstat (limited to 'zen/legacy_compiler.cpp')
-rw-r--r-- | zen/legacy_compiler.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/zen/legacy_compiler.cpp b/zen/legacy_compiler.cpp index 81efb4dd..6c5489d5 100644 --- a/zen/legacy_compiler.cpp +++ b/zen/legacy_compiler.cpp @@ -5,22 +5,24 @@ // ***************************************************************************** #include "legacy_compiler.h" -#ifdef __cpp_lib_to_chars - #error get rid of workarounds -#endif +#include <charconv> +/* 1. including <charconv> in header file blows up VC++: + - string_tools.h: "An internal error has occurred in the compiler. (compiler file 'd:\agent\_work\1\s\src\vctools\Compiler\Utc\src\p2\p2symtab.c', line 2618)" + - PCH: "fatal error C1076: compiler limit: internal heap limit reached" + => include in separate compilation unit + 2. Disable "C/C++ -> Code Generation -> Smaller Type Check" (and PCH usage!), at least for this compilation unit: https://github.com/microsoft/STL/pull/171 */ double zen::fromChars(const char* first, const char* last) { - return std::strtod(std::string(first, last).c_str(), nullptr); + double num = 0; + [[maybe_unused]] const std::from_chars_result rv = std::from_chars(first, last, num); + return num; } const char* zen::toChars(char* first, char* last, double num) { - const size_t bufSize = last - first; - const int charsWritten = std::snprintf(first, bufSize, "%g", num); - //C99: returns number of chars written if successful, < 0 or >= bufferSize on failure - - return 0 <= charsWritten && charsWritten < static_cast<int>(bufSize) ? - first + charsWritten : first; + const std::to_chars_result rv = std::to_chars(first, last, num); + return rv.ec == std::errc{} ? rv.ptr : first; } + |