mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 19:00:17 +02:00
This fixes compilation with libc++ 23, which has removed a number of unnecessary transitive includes in its headers. Include <cstdlib> in StringConv.h for std::strtoll and std::strtoull. Include <cstdlib> for the declarations of malloc/free/realloc/calloc in Alloc.cpp. (Without this, the functions we define end up with C++ name mangling.) Include <stdarg.h> in IO.cpp for va_start/va_end.
31 lines
798 B
C++
31 lines
798 B
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
#include <FEXCore/fextl/string.h>
|
|
|
|
#include <concepts>
|
|
#include <string_view>
|
|
#include <cstdlib>
|
|
|
|
namespace FEXCore::StrConv {
|
|
template<std::integral T>
|
|
bool Conv(std::string_view Value, T* Result) {
|
|
if constexpr (std::is_signed_v<T>) {
|
|
*Result = static_cast<T>(std::strtoll(Value.data(), nullptr, 0));
|
|
} else {
|
|
*Result = static_cast<T>(std::strtoull(Value.data(), nullptr, 0));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
template<typename T, typename = std::enable_if_t<std::is_enum_v<T>, T>>
|
|
bool Conv(std::string_view Value, T* Result) {
|
|
*Result = static_cast<T>(std::strtoull(Value.data(), nullptr, 0));
|
|
return true;
|
|
}
|
|
|
|
inline bool Conv(std::string_view Value, fextl::string* Result) {
|
|
*Result = Value;
|
|
return true;
|
|
}
|
|
} // namespace FEXCore::StrConv
|