Fix Mac build for Xcode 16.3 (#1558)
Some checks failed
Build check / build (push) Waiting to run
Generate translation template / generate-pot (push) Failing after 2s

This commit is contained in:
neebyA 2025-05-11 15:08:25 -07:00 committed by GitHub
parent 61484598fc
commit f801fc1fe8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,92 @@
#include "boost/nowide/convert.hpp"
#include <charconv>
// Definition for removed templates in Apple Clang 17
#if defined(__apple_build_version__) && (__apple_build_version__ >= 17000000)
namespace std {
template<>
struct char_traits<uint16be> {
using char_type = uint16be;
using int_type = int;
using off_type = streamoff;
using pos_type = streampos;
using state_type = mbstate_t;
static inline void constexpr assign(char_type& c1, const char_type& c2) noexcept {
c1 = c2;
}
static inline constexpr bool eq(char_type c1, char_type c2) noexcept {
return c1 == c2;
}
static inline constexpr bool lt(char_type c1, char_type c2) noexcept {
return c1 < c2;
}
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n) {
for (; n; --n, ++s1, ++s2) {
if (lt(*s1, *s2)) return -1;
if (lt(*s2, *s1)) return 1;
}
return 0;
}
static constexpr size_t length(const char_type* s) {
size_t len = 0;
for (; !eq(*s, char_type(0)); ++s) ++len;
return len;
}
static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a) {
for (; n; --n) {
if (eq(*s, a))
return s;
++s;
}
return nullptr;
}
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n) {
if (n == 0) return s1;
return static_cast<char_type*>(memmove(s1, s2, n * sizeof(char_type)));
}
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n) {
if (n == 0) return s1;
return static_cast<char_type*>(memcpy(s1, s2, n * sizeof(char_type)));
}
static constexpr char_type* assign(char_type* s, size_t n, char_type a) {
char_type* r = s;
for (; n; --n, ++s)
assign(*s, a);
return r;
}
static inline constexpr char_type to_char_type(int_type c) noexcept {
return char_type(c);
}
static inline constexpr int_type to_int_type(char_type c) noexcept {
return int_type(c);
}
static inline constexpr bool eq_int_type(int_type c1, int_type c2) noexcept {
return c1 == c2;
}
static inline constexpr int_type eof() noexcept {
return static_cast<int_type>(EOF);
}
static inline constexpr int_type not_eof(int_type c) noexcept {
return eq_int_type(c, eof()) ? ~eof() : c;
}
};
}
#endif
// todo - move the Cafe/PPC specific parts to CafeString.h eventually
namespace StringHelpers
{