1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Replace std::from_chars with std::stoull

the former was not widely supported, requiring newer compiler versions.

closes https://github.com/official-stockfish/Stockfish/pull/5313

No functional change
This commit is contained in:
Tomasz Sobczyk 2024-05-30 18:18:51 +02:00 committed by Disservin
parent f1bb4164bf
commit 86694b5914

View file

@ -42,16 +42,15 @@ using AdjustTokenPrivileges_t =
#endif #endif
#include <atomic> #include <atomic>
#include <charconv>
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <limits>
#include <mutex> #include <mutex>
#include <sstream> #include <sstream>
#include <string_view> #include <string_view>
#include <system_error>
#include "types.h" #include "types.h"
@ -598,13 +597,10 @@ void aligned_large_pages_free(void* mem) { std_aligned_free(mem); }
#endif #endif
size_t str_to_size_t(const std::string& s) { size_t str_to_size_t(const std::string& s) {
size_t value; unsigned long long value = std::stoull(s);
auto result = std::from_chars(s.data(), s.data() + s.size(), value); if (value > std::numeric_limits<size_t>::max())
if (result.ec != std::errc())
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
return static_cast<size_t>(value);
return value;
} }
std::string CommandLine::get_binary_directory(std::string argv0) { std::string CommandLine::get_binary_directory(std::string argv0) {