From 01d0bdf1bbb4ad3604a6d261b8648b870b1f0131 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 28 Sep 2024 22:23:45 -0700 Subject: [PATCH] Modernize `std::is_sorted` with ranges In OGLConfig.cpp, `std::views::reverse` is used rather than sorting using `std::ranges::greater` in order to parallel other instances of reverse iteration in the function. --- Source/Core/UICommon/GameFile.cpp | 2 +- Source/Core/VideoBackends/OGL/OGLConfig.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index 7603463138..9151aec796 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -613,7 +613,7 @@ bool GameFile::CheckIfTwoDiscGame(const std::string& game_id) const "S6T", "SDQ", }; - static_assert(std::is_sorted(two_disc_game_id_prefixes.begin(), two_disc_game_id_prefixes.end())); + static_assert(std::ranges::is_sorted(two_disc_game_id_prefixes)); std::string_view game_id_prefix(game_id.data(), GAME_ID_PREFIX_SIZE); return std::binary_search(two_disc_game_id_prefixes.begin(), two_disc_game_id_prefixes.end(), diff --git a/Source/Core/VideoBackends/OGL/OGLConfig.cpp b/Source/Core/VideoBackends/OGL/OGLConfig.cpp index 387333b898..f53d38645b 100644 --- a/Source/Core/VideoBackends/OGL/OGLConfig.cpp +++ b/Source/Core/VideoBackends/OGL/OGLConfig.cpp @@ -4,6 +4,7 @@ #include "VideoBackends/OGL/OGLConfig.h" #include +#include #include #include @@ -585,7 +586,7 @@ bool PopulateConfig(GLContext* m_main_gl_context) glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, colorInternalFormat, GL_SAMPLES, num_color_sample_counts, reinterpret_cast(color_aa_modes.data())); - ASSERT_MSG(VIDEO, std::is_sorted(color_aa_modes.rbegin(), color_aa_modes.rend()), + ASSERT_MSG(VIDEO, std::ranges::is_sorted(color_aa_modes | std::views::reverse), "GPU driver didn't return sorted color AA modes: [{}]", fmt::join(color_aa_modes, ", ")); } @@ -614,7 +615,7 @@ bool PopulateConfig(GLContext* m_main_gl_context) glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, depthInternalFormat, GL_SAMPLES, num_depth_sample_counts, reinterpret_cast(depth_aa_modes.data())); - ASSERT_MSG(VIDEO, std::is_sorted(depth_aa_modes.rbegin(), depth_aa_modes.rend()), + ASSERT_MSG(VIDEO, std::ranges::is_sorted(depth_aa_modes | std::views::reverse), "GPU driver didn't return sorted depth AA modes: [{}]", fmt::join(depth_aa_modes, ", ")); }