refactor: downgrade to C++20

This commit is contained in:
Tropical 2026-04-10 17:12:35 -05:00
parent ff7baaac3b
commit b0fac9fbc6
9 changed files with 17 additions and 16 deletions

View file

@ -6,7 +6,7 @@ project(
version: '0.1.0',
meson_version: '>= 1.3',
default_options: [
'cpp_std=c++23',
'cpp_std=c++20',
'warning_level=0',
'unity=on', # merge source files per target
'unity_size=8', # TODO: mess around with this

View file

@ -1,6 +1,6 @@
project('simdutf',
'cpp',
default_options: ['cpp_std=c++23'],
default_options: ['cpp_std=c++20'],
version: '8.2.0',
meson_version: '>= 1.1',
license: ['MIT'],

View file

@ -589,7 +589,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() {
backupTexture = getTextureId(m_skinIndex);
if (m_skinIndex ==
std::to_underlying(EDefaultSkins::ServerSelected)) {
static_cast<int>(EDefaultSkins::ServerSelected)) {
skinName = app.GetString(IDS_DEFAULT_SKINS);
} else {
skinName = wchDefaultNamesA[m_skinIndex];
@ -908,8 +908,8 @@ int UIScene_SkinSelectMenu::getNextSkinIndex(int sourceIndex) {
++nextSkin;
if (m_packIndex == SKIN_SELECT_PACK_DEFAULT &&
nextSkin >= std::to_underlying(EDefaultSkins::Count)) {
nextSkin = std::to_underlying(EDefaultSkins::ServerSelected);
nextSkin >= static_cast<int>(EDefaultSkins::Count)) {
nextSkin = static_cast<int>(EDefaultSkins::ServerSelected);
} else if (m_currentPack != nullptr &&
nextSkin >= m_currentPack->getSkinCount()) {
nextSkin = 0;
@ -933,7 +933,7 @@ int UIScene_SkinSelectMenu::getPreviousSkinIndex(int sourceIndex) {
default:
if (previousSkin == 0) {
if (m_packIndex == SKIN_SELECT_PACK_DEFAULT) {
previousSkin = std::to_underlying(EDefaultSkins::Count) - 1;
previousSkin = static_cast<int>(EDefaultSkins::Count) - 1;
} else if (m_currentPack != nullptr) {
previousSkin = m_currentPack->getSkinCount() - 1;
}

View file

@ -25,7 +25,7 @@ class UILayer;
class UIScene_SkinSelectMenu : public UIScene {
private:
static const char*
wchDefaultNamesA[std::to_underlying(EDefaultSkins::Count)];
wchDefaultNamesA[static_cast<size_t>(EDefaultSkins::Count)];
// 4J Stu - How many to show on each side of the main control
static const int sidePreviewControls = 4;

View file

@ -1268,7 +1268,7 @@ bool UIController::NavigateToScene(int iPad, EUIScene scene, void* initData,
setFullscreenMenuDisplayed(true);
}
std::println(stderr, "TIMER: Navigate to scene: Elapsed time {:.6f}",
fprintf(stderr, "TIMER: Navigate to scene: Elapsed time %.6f",
timer.elapsed_seconds());
return success;

View file

@ -535,7 +535,7 @@ void Player::ride(std::shared_ptr<Entity> e) {
void Player::setPlayerDefaultSkin(EDefaultSkins skin) {
#if !defined(_CONTENT_PACKAGE)
printf("Setting default skin to %d for player %s\n",
std::to_underlying(skin), name.c_str());
static_cast<int>(skin), name.c_str());
#endif
m_skinIndex = skin;
}

View file

@ -140,7 +140,7 @@ void setPriorityPlatform(std::thread& threadHandle, bool isSelf,
handle = ::GetCurrentThread();
else
return;
(void)::SetThreadPriority(handle, std::to_underlying(priority));
(void)::SetThreadPriority(handle, static_cast<int>(priority));
#elif defined(__linux__)
std::int64_t tid = 0;

View file

@ -40,7 +40,7 @@ public:
[[nodiscard]] static constexpr std::size_t BucketIndex(
Bucket bucket) noexcept {
return static_cast<std::size_t>(std::to_underlying(bucket));
return static_cast<size_t>(bucket);
}
[[nodiscard]] static constexpr std::size_t BucketCount() noexcept {

View file

@ -81,11 +81,12 @@ public:
std::chrono::duration<double, std::milli>(elapsed).count();
try {
name_.empty()
? std::println(stderr, "[TIMER] {:.3f} ms ({}:{})", ms, file_,
line_)
: std::println(stderr, "[TIMER] {} - {:.3f} ms ({}:{})", name_,
ms, file_, line_);
const auto log =
name_.empty() ? std::format("[TIMER] {:.3f} ms ({}:{})\n", ms,
file_, line_)
: std::format("[TIMER] {} - {:.3f} ms ({}:{})\n",
name_, ms, file_, line_);
std::fputs(log.c_str(), stderr);
} catch (...) {
std::fprintf(stderr, "[TIMER] %.3f ms\n", ms);
}