Modernize range operations

This commit is contained in:
Dr. Dystopia 2024-07-22 06:18:30 +02:00
parent 93617e96c3
commit 5c690c5623
145 changed files with 527 additions and 597 deletions

View File

@ -168,8 +168,8 @@ const std::string& GetSystemName(System system)
std::optional<System> GetSystemFromName(const std::string& name)
{
const auto system = std::find_if(system_to_name.begin(), system_to_name.end(),
[&name](const auto& entry) { return entry.second == name; });
const auto system = std::ranges::find_if(
system_to_name, [&name](const auto& entry) { return entry.second == name; });
if (system != system_to_name.end())
return system->first;

View File

@ -24,7 +24,7 @@ struct Elt
{
bool IsZero() const
{
return std::all_of(data.begin(), data.end(), [](u8 b) { return b == 0; });
return std::ranges::all_of(data, [](u8 b) { return b == 0; });
}
void MulX()
@ -252,8 +252,8 @@ Signature Sign(const u8* key, const u8* hash)
bn_mul(s.data.data(), minv, kk, ec_N, 30);
Signature signature;
std::copy(r.data.cbegin(), r.data.cend(), signature.begin());
std::copy(s.data.cbegin(), s.data.cend(), signature.begin() + 30);
std::ranges::copy(r.data, signature.begin());
std::ranges::copy(s.data, signature.begin() + 30);
return signature;
}

View File

@ -63,8 +63,8 @@ const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const
void MemoryPatches::UnsetPatch(const Core::CPUThreadGuard& guard, u32 address)
{
const auto it = std::find_if(m_patches.begin(), m_patches.end(),
[address](const auto& patch) { return patch.address == address; });
const auto it = std::ranges::find_if(
m_patches, [address](const auto& patch) { return patch.address == address; });
if (it == m_patches.end())
return;
@ -91,7 +91,7 @@ void MemoryPatches::DisablePatch(const Core::CPUThreadGuard& guard, std::size_t
bool MemoryPatches::HasEnabledPatch(u32 address) const
{
return std::any_of(m_patches.begin(), m_patches.end(), [address](const MemoryPatch& patch) {
return std::ranges::any_of(m_patches, [address](const MemoryPatch& patch) {
return patch.address == address && patch.is_enabled == MemoryPatch::State::Enabled;
});
}

View File

@ -79,7 +79,7 @@ void Watches::DisableWatch(std::size_t index)
bool Watches::HasEnabledWatch(u32 address) const
{
return std::any_of(m_watches.begin(), m_watches.end(), [address](const auto& watch) {
return std::ranges::any_of(m_watches, [address](const auto& watch) {
return watch.address == address && watch.is_enabled == Watch::State::Enabled;
});
}

View File

@ -485,10 +485,9 @@ static bool Pack(const std::function<bool()>& cancelled, const File::FSTEntry& e
static void SortFST(File::FSTEntry* root)
{
std::sort(root->children.begin(), root->children.end(),
[](const File::FSTEntry& lhs, const File::FSTEntry& rhs) {
return lhs.virtualName < rhs.virtualName;
});
std::ranges::sort(root->children, [](const File::FSTEntry& lhs, const File::FSTEntry& rhs) {
return lhs.virtualName < rhs.virtualName;
});
for (auto& child : root->children)
SortFST(&child);
}
@ -729,7 +728,7 @@ static bool Unpack(const std::function<bool()>& cancelled, const std::string pat
const bool is_path_traversal_attack =
(childname.find("\\") != std::string_view::npos) ||
(childname.find('/') != std::string_view::npos) ||
std::all_of(childname.begin(), childname.end(), [](char c) { return c == '.'; });
std::ranges::all_of(childname, [](char c) { return c == '.'; });
if (is_path_traversal_attack)
{
ERROR_LOG_FMT(

View File

@ -41,7 +41,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// N.B. This avoids doing any copies
auto ext_matches = [&native_exts](const fs::path& path) {
const std::basic_string_view<fs::path::value_type> native_path = path.native();
return std::any_of(native_exts.cbegin(), native_exts.cend(), [&native_path](const auto& ext) {
return std::ranges::any_of(native_exts, [&native_path](const auto& ext) {
const auto compare_len = ext.native().length();
if (native_path.length() < compare_len)
return false;
@ -97,8 +97,8 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// Remove duplicates (occurring because caller gave e.g. duplicate or overlapping directories -
// not because std::filesystem returns duplicates). Also note that this pathname-based uniqueness
// isn't as thorough as std::filesystem::equivalent.
std::sort(result.begin(), result.end());
result.erase(std::unique(result.begin(), result.end()), result.end());
std::ranges::sort(result);
result.erase(std::ranges::unique(result).begin(), result.end());
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
// std::filesystem uses the OS separator.
@ -107,7 +107,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
if constexpr (os_separator != DIR_SEP_CHR)
{
for (auto& path : result)
std::replace(path.begin(), path.end(), '\\', DIR_SEP_CHR);
std::ranges::replace(path, '\\', DIR_SEP_CHR);
}
return result;

View File

@ -446,7 +446,7 @@ FSTEntry ScanDirectoryTree(std::string directory, bool recursive)
// about with directory separators (for host paths - emulated paths may require it) and instead
// use fs::path to interact with them.
auto wpath = path.wstring();
std::replace(wpath.begin(), wpath.end(), L'\\', L'/');
std::ranges::replace(wpath, L'\\', L'/');
return WStringToUTF8(wpath);
#else
return PathToString(path);

View File

@ -85,7 +85,7 @@ bool IniFile::Section::Delete(std::string_view key)
return false;
values.erase(it);
keys_order.erase(std::find(keys_order.begin(), keys_order.end(), key));
keys_order.erase(std::ranges::find(keys_order, key));
return true;
}

View File

@ -22,9 +22,8 @@ struct CaseInsensitiveStringCompare
bool operator()(std::string_view a, std::string_view b) const
{
return std::lexicographical_compare(
a.begin(), a.end(), b.begin(), b.end(),
[](char lhs, char rhs) { return Common::ToLower(lhs) < Common::ToLower(rhs); });
return std::ranges::lexicographical_compare(
a, b, [](char lhs, char rhs) { return Common::ToLower(lhs) < Common::ToLower(rhs); });
}
static bool IsEqual(std::string_view a, std::string_view b)
@ -32,9 +31,8 @@ struct CaseInsensitiveStringCompare
if (a.size() != b.size())
return false;
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char lhs, char rhs) {
return Common::ToLower(lhs) == Common::ToLower(rhs);
});
return std::ranges::equal(
a, b, [](char lhs, char rhs) { return Common::ToLower(lhs) == Common::ToLower(rhs); });
}
};

View File

@ -106,13 +106,13 @@ static bool IsIllegalCharacter(char c)
{
static constexpr auto illegal_chars = {'\"', '*', '/', ':', '<', '>', '?', '\\', '|', '\x7f'};
return static_cast<unsigned char>(c) <= 0x1F ||
std::find(illegal_chars.begin(), illegal_chars.end(), c) != illegal_chars.end();
std::ranges::find(illegal_chars, c) != illegal_chars.end();
}
std::string EscapeFileName(const std::string& filename)
{
// Prevent paths from containing special names like ., .., ..., ...., and so on
if (std::all_of(filename.begin(), filename.end(), [](char c) { return c == '.'; }))
if (std::ranges::all_of(filename, [](char c) { return c == '.'; }))
return ReplaceAll(filename, ".", "__2e__");
// Escape all double underscores since we will use double underscores for our escape sequences
@ -169,8 +169,7 @@ std::string UnescapeFileName(const std::string& filename)
bool IsFileNameSafe(const std::string_view filename)
{
return !filename.empty() &&
!std::all_of(filename.begin(), filename.end(), [](char c) { return c == '.'; }) &&
std::none_of(filename.begin(), filename.end(), IsIllegalCharacter);
return !filename.empty() && !std::ranges::all_of(filename, [](char c) { return c == '.'; }) &&
std::ranges::none_of(filename, IsIllegalCharacter);
}
} // namespace Common

View File

@ -36,10 +36,10 @@ MACAddress GenerateMacAddress(const MACConsumer type)
switch (type)
{
case MACConsumer::BBA:
std::copy(oui_bba.begin(), oui_bba.end(), mac.begin());
std::ranges::copy(oui_bba, mac.begin());
break;
case MACConsumer::IOS:
std::copy(oui_ios.begin(), oui_ios.end(), mac.begin());
std::ranges::copy(oui_ios, mac.begin());
break;
}

View File

@ -233,8 +233,8 @@ std::string_view StripQuotes(std::string_view s)
// Turns "\n\rhello" into " hello".
void ReplaceBreaksWithSpaces(std::string& str)
{
std::replace(str.begin(), str.end(), '\r', ' ');
std::replace(str.begin(), str.end(), '\n', ' ');
std::ranges::replace(str, '\r', ' ');
std::ranges::replace(str, '\n', ' ');
}
void TruncateToCString(std::string* s)
@ -374,8 +374,7 @@ std::string JoinStrings(const std::vector<std::string>& strings, const std::stri
return "";
std::ostringstream res;
std::copy(strings.begin(), strings.end(),
std::ostream_iterator<std::string>(res, delimiter.c_str()));
std::ranges::copy(strings, std::ostream_iterator<std::string>(res, delimiter.c_str()));
// Drop the trailing delimiter.
std::string joined = res.str();
@ -417,8 +416,7 @@ void StringPopBackIf(std::string* s, char c)
size_t StringUTF8CodePointCount(std::string_view str)
{
return str.size() -
std::count_if(str.begin(), str.end(), [](char c) -> bool { return (c & 0xC0) == 0x80; });
return str.size() - std::ranges::count_if(str, [](char c) -> bool { return (c & 0xC0) == 0x80; });
}
#ifdef _WIN32
@ -670,12 +668,12 @@ std::string GetEscapedHtml(std::string html)
void ToLower(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); });
std::ranges::transform(*str, str->begin(), [](char c) { return Common::ToLower(c); });
}
void ToUpper(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToUpper(c); });
std::ranges::transform(*str, str->begin(), [](char c) { return Common::ToUpper(c); });
}
bool CaseInsensitiveEquals(std::string_view a, std::string_view b)

View File

@ -120,8 +120,8 @@ void ApplyCodes(std::span<const ARCode> codes)
std::lock_guard guard(s_lock);
s_disable_logging = false;
s_active_codes.clear();
std::copy_if(codes.begin(), codes.end(), std::back_inserter(s_active_codes),
[](const ARCode& code) { return code.enabled; });
std::ranges::copy_if(codes, std::back_inserter(s_active_codes),
[](const ARCode& code) { return code.enabled; });
s_active_codes.shrink_to_fit();
}
@ -136,8 +136,8 @@ void UpdateSyncedCodes(std::span<const ARCode> codes)
{
s_synced_codes.clear();
s_synced_codes.reserve(codes.size());
std::copy_if(codes.begin(), codes.end(), std::back_inserter(s_synced_codes),
[](const ARCode& code) { return code.enabled; });
std::ranges::copy_if(codes, std::back_inserter(s_synced_codes),
[](const ARCode& code) { return code.enabled; });
s_synced_codes.shrink_to_fit();
}
@ -148,8 +148,8 @@ std::vector<ARCode> ApplyAndReturnCodes(std::span<const ARCode> codes)
std::lock_guard guard(s_lock);
s_disable_logging = false;
s_active_codes.clear();
std::copy_if(codes.begin(), codes.end(), std::back_inserter(s_active_codes),
[](const ARCode& code) { return code.enabled; });
std::ranges::copy_if(codes, std::back_inserter(s_active_codes),
[](const ARCode& code) { return code.enabled; });
}
s_active_codes.shrink_to_fit();

View File

@ -39,7 +39,7 @@ static std::optional<DiscIO::Language> TryParseLanguage(const std::string& local
if (split_locale[0] == "zh")
{
const auto locale_contains = [&split_locale](std::string_view str) {
return std::find(split_locale.cbegin(), split_locale.cend(), str) != split_locale.cend();
return std::ranges::find(split_locale, str) != split_locale.cend();
};
if (locale_contains("Hans"))
@ -59,7 +59,7 @@ static std::optional<DiscIO::Language> TryParseLanguage(const std::string& local
"ja", "en", "de", "fr", "es", "it", "nl", "zh", "zh", "ko",
};
const auto it = std::find(LANGUAGES.cbegin(), LANGUAGES.cend(), split_locale[0]);
const auto it = std::ranges::find(LANGUAGES, split_locale[0]);
if (it == LANGUAGES.cend())
return std::nullopt;
@ -142,7 +142,7 @@ static std::optional<u8> ComputeDefaultCountry()
if (country == "BQ" || country == "CW" || country == "SX")
country = "AN";
const auto it = std::find(COUNTRIES.cbegin(), COUNTRIES.cend(), country);
const auto it = std::ranges::find(COUNTRIES, country);
if (it == COUNTRIES.cend())
return std::nullopt;

View File

@ -115,8 +115,9 @@ public:
{
const Config::Location location{system.first, section_name, value.first};
const bool load_disallowed =
std::any_of(begin(s_setting_disallowed), end(s_setting_disallowed),
[&location](const Config::Location* l) { return *l == location; });
std::ranges::any_of(s_setting_disallowed, [&location](const Config::Location* l) {
return *l == location;
});
if (load_disallowed)
continue;

View File

@ -147,16 +147,15 @@ static Location MapINIToRealLocation(const std::string& section, const std::stri
static std::pair<std::string, std::string> GetINILocationFromConfig(const Location& location)
{
static const INIToLocationMap& ini_to_location = GetINIToLocationMap();
const auto it = std::find_if(ini_to_location.begin(), ini_to_location.end(),
[&location](const auto& entry) { return entry.second == location; });
const auto it = std::ranges::find_if(
ini_to_location, [&location](const auto& entry) { return entry.second == location; });
if (it != ini_to_location.end())
return it->first;
static const INIToSectionMap& ini_to_section = GetINIToSectionMap();
const auto it2 =
std::find_if(ini_to_section.begin(), ini_to_section.end(), [&location](const auto& entry) {
return entry.second.first == location.system && entry.second.second == location.section;
});
const auto it2 = std::ranges::find_if(ini_to_section, [&location](const auto& entry) {
return entry.second.first == location.system && entry.second.second == location.section;
});
if (it2 != ini_to_section.end())
return {it2->first, location.key};

View File

@ -20,8 +20,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
static constexpr std::array<Config::System, 3> systems_not_saveable = {
Config::System::GCPad, Config::System::WiiPad, Config::System::GCKeyboard};
if (std::find(begin(systems_not_saveable), end(systems_not_saveable), config_location.system) ==
end(systems_not_saveable))
if (std::ranges::find(systems_not_saveable, config_location.system) == end(systems_not_saveable))
{
return true;
}
@ -32,9 +31,9 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::WIIMOTE_BB_SOURCE.GetLocation(),
};
return std::any_of(begin(s_setting_saveable), end(s_setting_saveable),
[&config_location](const Config::Location* location) {
return *location == config_location;
});
return std::ranges::any_of(s_setting_saveable,
[&config_location](const Config::Location* location) {
return *location == config_location;
});
}
} // namespace ConfigLoaders

View File

@ -265,7 +265,7 @@ struct SetGameMetadata
std::string executable_path = executable.path;
constexpr char BACKSLASH = '\\';
constexpr char FORWARDSLASH = '/';
std::replace(executable_path.begin(), executable_path.end(), BACKSLASH, FORWARDSLASH);
std::ranges::replace(executable_path, BACKSLASH, FORWARDSLASH);
config->SetRunningGameMetadata(SConfig::MakeGameID(PathToFileName(executable_path)));
Host_TitleChanged();

View File

@ -194,7 +194,7 @@ void DisplayMessage(std::string message, int time_in_ms)
return;
// Actually displaying non-ASCII could cause things to go pear-shaped
if (!std::all_of(message.begin(), message.end(), Common::IsPrintableCharacter))
if (!std::ranges::all_of(message, Common::IsPrintableCharacter))
return;
OSD::AddMessage(std::move(message), time_in_ms);

View File

@ -205,7 +205,7 @@ void CoreTimingManager::DoState(PointerWrap& p)
// When loading from a save state, we must assume the Event order is random and meaningless.
// The exact layout of the heap in memory is implementation defined, therefore it is platform
// and library version specific.
std::make_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>());
std::ranges::make_heap(m_event_queue, std::greater<Event>());
// The stave state has changed the time, so our previous Throttle targets are invalid.
// Especially when global_time goes down; So we create a fake throttle update.
@ -263,7 +263,7 @@ void CoreTimingManager::ScheduleEvent(s64 cycles_into_future, EventType* event_t
ForceExceptionCheck(cycles_into_future);
m_event_queue.emplace_back(Event{timeout, m_event_fifo_id++, userdata, event_type});
std::push_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>());
std::ranges::push_heap(m_event_queue, std::greater<Event>());
}
else
{
@ -288,7 +288,7 @@ void CoreTimingManager::RemoveEvent(EventType* event_type)
// Removing random items breaks the invariant so we have to re-establish it.
if (erased != 0)
{
std::make_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>());
std::ranges::make_heap(m_event_queue, std::greater<Event>());
}
}
@ -317,7 +317,7 @@ void CoreTimingManager::MoveEvents()
{
ev.fifo_order = m_event_fifo_id++;
m_event_queue.emplace_back(std::move(ev));
std::push_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>());
std::ranges::push_heap(m_event_queue, std::greater<Event>());
}
}
@ -341,7 +341,7 @@ void CoreTimingManager::Advance()
while (!m_event_queue.empty() && m_event_queue.front().time <= m_globals.global_timer)
{
Event evt = std::move(m_event_queue.front());
std::pop_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>());
std::ranges::pop_heap(m_event_queue, std::greater<Event>());
m_event_queue.pop_back();
Throttle(evt.time);

View File

@ -143,10 +143,10 @@ bool SDSP::Initialize(const DSPInitOptions& opts)
std::memset(&r, 0, sizeof(r));
std::fill(std::begin(reg_stack_ptrs), std::end(reg_stack_ptrs), 0);
std::ranges::fill(reg_stack_ptrs, 0);
for (auto& stack : reg_stacks)
std::fill(std::begin(stack), std::end(stack), 0);
std::ranges::fill(stack, 0);
// Fill IRAM with HALT opcodes.
std::fill(iram, iram + DSP_IRAM_SIZE, 0x0021);
@ -156,7 +156,7 @@ bool SDSP::Initialize(const DSPInitOptions& opts)
// Copied from a real console after the custom UCode has been loaded.
// These are the indexing wrapping registers.
std::fill(std::begin(r.wr), std::end(r.wr), 0xffff);
std::ranges::fill(r.wr, 0xffff);
r.sr |= SR_INT_ENABLE;
r.sr |= SR_EXT_INT_ENABLE;
@ -172,7 +172,7 @@ bool SDSP::Initialize(const DSPInitOptions& opts)
void SDSP::Reset()
{
pc = DSP_RESET_VECTOR;
std::fill(std::begin(r.wr), std::end(r.wr), 0xffff);
std::ranges::fill(r.wr, 0xffff);
}
void SDSP::Shutdown()

View File

@ -40,7 +40,7 @@ DSPEmitter::DSPEmitter(DSPCore& dsp)
m_stub_entry_point = CompileStub();
// Clear all of the block references
std::fill(m_blocks.begin(), m_blocks.end(), (DSPCompiledCode)m_stub_entry_point);
std::ranges::fill(m_blocks, (DSPCompiledCode)m_stub_entry_point);
}
DSPEmitter::~DSPEmitter()

View File

@ -63,8 +63,8 @@ bool LabelMap::RegisterLabel(std::string label, u16 lval, LabelType type)
void LabelMap::DeleteLabel(std::string_view label)
{
const auto iter = std::find_if(labels.cbegin(), labels.cend(),
[&label](const auto& entry) { return entry.name == label; });
const auto iter =
std::ranges::find_if(labels, [&label](const auto& entry) { return entry.name == label; });
if (iter == labels.cend())
return;

View File

@ -72,9 +72,9 @@ void BranchWatch::Save(const CPUThreadGuard& guard, std::FILE* file) const
const auto routine = [&](const Collection& collection, bool is_virtual, bool condition) {
for (const Collection::value_type& kv : collection)
{
const auto iter = std::find_if(
m_selection.begin(), m_selection.end(),
[&](const Selection::value_type& value) { return value.collection_ptr == &kv; });
const auto iter = std::ranges::find_if(m_selection, [&](const Selection::value_type& value) {
return value.collection_ptr == &kv;
});
fmt::println(file, "{:08x} {:08x} {:08x} {} {} {:x}", kv.first.origin_addr,
kv.first.destin_addr, kv.first.original_inst.hex, kv.second.total_hits,
kv.second.hits_snapshot,
@ -303,8 +303,7 @@ void BranchWatch::UpdateHitsSnapshot()
void BranchWatch::ClearSelectionInspection()
{
std::for_each(m_selection.begin(), m_selection.end(),
[](Selection::value_type& value) { value.inspection = {}; });
std::ranges::for_each(m_selection, [](Selection::value_type& value) { value.inspection = {}; });
}
void BranchWatch::SetSelectedInspected(std::size_t idx, SelectionInspection inspection)

View File

@ -252,14 +252,14 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
return HitType::SKIP;
// The reg_itr will be used later for erasing.
auto reg_itr = std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(), instr.reg0);
auto reg_itr = std::ranges::find(m_reg_autotrack, instr.reg0);
const bool match_reg123 =
(!instr.reg1.empty() && std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(),
instr.reg1) != m_reg_autotrack.end()) ||
(!instr.reg2.empty() && std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(),
instr.reg2) != m_reg_autotrack.end()) ||
(!instr.reg3.empty() && std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(),
instr.reg3) != m_reg_autotrack.end());
(!instr.reg1.empty() &&
std::ranges::find(m_reg_autotrack, instr.reg1) != m_reg_autotrack.end()) ||
(!instr.reg2.empty() &&
std::ranges::find(m_reg_autotrack, instr.reg2) != m_reg_autotrack.end()) ||
(!instr.reg3.empty() &&
std::ranges::find(m_reg_autotrack, instr.reg3) != m_reg_autotrack.end());
const bool match_reg0 = reg_itr != m_reg_autotrack.end();
if (!match_reg0 && !match_reg123 && !mem_hit)

View File

@ -253,7 +253,7 @@ Common::Debug::Threads PPCDebugInterface::GetThreads(const Core::CPUThreadGuard&
const auto insert_threads = [&guard, &threads, &visited_addrs](u32 addr, auto get_next_addr) {
while (addr != 0 && PowerPC::MMU::HostIsRAMAddress(guard, addr))
{
if (std::find(visited_addrs.begin(), visited_addrs.end(), addr) != visited_addrs.end())
if (std::ranges::find(visited_addrs, addr) != visited_addrs.end())
break;
visited_addrs.push_back(addr);
auto thread = std::make_unique<Core::Debug::OSThreadView>(guard, addr);
@ -266,7 +266,7 @@ Common::Debug::Threads PPCDebugInterface::GetThreads(const Core::CPUThreadGuard&
const u32 prev_addr = active_thread->Data().thread_link.prev;
insert_threads(prev_addr, [](const auto& thread) { return thread.Data().thread_link.prev; });
std::reverse(threads.begin(), threads.end());
std::ranges::reverse(threads);
const u32 next_addr = active_thread->Data().thread_link.next;
threads.emplace_back(std::move(active_thread));

View File

@ -500,7 +500,7 @@ void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate)
else
mem = &memory.GetRAM()[memUpdate.address & memory.GetRamMask()];
std::copy(memUpdate.data.begin(), memUpdate.data.end(), mem);
std::ranges::copy(memUpdate.data, mem);
}
void FifoPlayer::WriteFifo(const u8* data, u32 start, u32 end)

View File

@ -240,8 +240,8 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
m_Ram.resize(memory.GetRamSize());
m_ExRam.resize(memory.GetExRamSize());
std::fill(m_Ram.begin(), m_Ram.end(), 0);
std::fill(m_ExRam.begin(), m_ExRam.end(), 0);
std::ranges::fill(m_Ram, 0);
std::ranges::fill(m_ExRam, 0);
m_File->SetIsWii(m_system.IsWii());

View File

@ -48,7 +48,7 @@ bool operator!=(const GeckoCode::Code& lhs, const GeckoCode::Code& rhs)
// return true if a code exists
bool GeckoCode::Exist(u32 address, u32 data) const
{
return std::find_if(codes.begin(), codes.end(), [&](const Code& code) {
return std::ranges::find_if(codes, [&](const Code& code) {
return code.address == address && code.data == data;
}) != codes.end();
}
@ -74,8 +74,8 @@ void SetActiveCodes(std::span<const GeckoCode> gcodes)
if (Config::AreCheatsEnabled())
{
s_active_codes.reserve(gcodes.size());
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
[](const GeckoCode& code) { return code.enabled; });
std::ranges::copy_if(gcodes, std::back_inserter(s_active_codes),
[](const GeckoCode& code) { return code.enabled; });
}
s_active_codes.shrink_to_fit();
@ -93,8 +93,8 @@ void UpdateSyncedCodes(std::span<const GeckoCode> gcodes)
{
s_synced_codes.clear();
s_synced_codes.reserve(gcodes.size());
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_synced_codes),
[](const GeckoCode& code) { return code.enabled; });
std::ranges::copy_if(gcodes, std::back_inserter(s_synced_codes),
[](const GeckoCode& code) { return code.enabled; });
s_synced_codes.shrink_to_fit();
}
@ -106,8 +106,8 @@ std::vector<GeckoCode> SetAndReturnActiveCodes(std::span<const GeckoCode> gcodes
if (Config::AreCheatsEnabled())
{
s_active_codes.reserve(gcodes.size());
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
[](const GeckoCode& code) { return code.enabled; });
std::ranges::copy_if(gcodes, std::back_inserter(s_active_codes),
[](const GeckoCode& code) { return code.enabled; });
}
s_active_codes.shrink_to_fit();

View File

@ -231,8 +231,8 @@ bool IsEnabled(HookFlag flag, PowerPC::CoreMode mode)
u32 UnPatch(Core::System& system, std::string_view patch_name)
{
const auto patch = std::find_if(std::begin(os_patches), std::end(os_patches),
[&](const Hook& p) { return patch_name == p.name; });
const auto patch =
std::ranges::find_if(os_patches, [&](const Hook& p) { return patch_name == p.name; });
if (patch == std::end(os_patches))
return 0;

View File

@ -331,18 +331,16 @@ private:
std::vector<AccessorMapping>::iterator FindAppropriateAccessor(const Core::CPUThreadGuard& guard,
u32 address)
{
return std::find_if(m_accessor_mappings.begin(), m_accessor_mappings.end(),
[&guard, address](const AccessorMapping& a) {
return a.accessors->IsValidAddress(guard, address - a.base);
});
return std::ranges::find_if(m_accessor_mappings, [&guard, address](const AccessorMapping& a) {
return a.accessors->IsValidAddress(guard, address - a.base);
});
}
std::vector<AccessorMapping>::const_iterator
FindAppropriateAccessor(const Core::CPUThreadGuard& guard, u32 address) const
{
return std::find_if(m_accessor_mappings.begin(), m_accessor_mappings.end(),
[&guard, address](const AccessorMapping& a) {
return a.accessors->IsValidAddress(guard, address - a.base);
});
return std::ranges::find_if(m_accessor_mappings, [&guard, address](const AccessorMapping& a) {
return a.accessors->IsValidAddress(guard, address - a.base);
});
}
};

View File

@ -101,8 +101,8 @@ std::pair<GCMemcardErrorCode, std::optional<GCMemcard>> GCMemcard::Open(std::str
MBIT_SIZE_MEMORY_CARD_2043,
}};
if (!std::any_of(valid_megabits.begin(), valid_megabits.end(),
[filesize_megabits](u64 mbits) { return mbits == filesize_megabits; }))
if (!std::ranges::any_of(valid_megabits,
[filesize_megabits](u64 mbits) { return mbits == filesize_megabits; }))
{
error_code.Set(GCMemcardValidityIssues::INVALID_CARD_SIZE);
return std::make_pair(error_code, std::nullopt);
@ -1301,8 +1301,8 @@ GCMemcardErrorCode Header::CheckForErrors(u16 card_size_mbits) const
error_code.Set(GCMemcardValidityIssues::MISMATCHED_CARD_SIZE);
// unused areas, should always be filled with 0xFF
if (std::any_of(m_unused_1.begin(), m_unused_1.end(), [](u8 val) { return val != 0xFF; }) ||
std::any_of(m_unused_2.begin(), m_unused_2.end(), [](u8 val) { return val != 0xFF; }))
if (std::ranges::any_of(m_unused_1, [](u8 val) { return val != 0xFF; }) ||
std::ranges::any_of(m_unused_2, [](u8 val) { return val != 0xFF; }))
{
error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA);
}
@ -1366,7 +1366,7 @@ GCMemcardErrorCode Directory::CheckForErrors() const
error_code.Set(GCMemcardValidityIssues::INVALID_CHECKSUM);
// unused area, should always be filled with 0xFF
if (std::any_of(m_padding.begin(), m_padding.end(), [](u8 val) { return val != 0xFF; }))
if (std::ranges::any_of(m_padding, [](u8 val) { return val != 0xFF; }))
error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA);
return error_code;

View File

@ -146,8 +146,8 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
if (!gci_file.ReadBytes(&gci.m_gci_header, Memcard::DENTRY_SIZE))
continue;
const auto same_identity_save_it = std::find_if(
loaded_saves.begin(), loaded_saves.end(), [&gci](const Memcard::DEntry& entry) {
const auto same_identity_save_it =
std::ranges::find_if(loaded_saves, [&gci](const Memcard::DEntry& entry) {
return Memcard::HasSameIdentity(gci.m_gci_header, entry);
});
if (same_identity_save_it != loaded_saves.end())

View File

@ -93,7 +93,7 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
std::vector<u8> response = m_core->GetJoybusResponse();
if (response.empty())
return -1;
std::copy(response.begin(), response.end(), buffer);
std::ranges::copy(response, buffer);
#ifdef _DEBUG
const Common::Log::LogLevel log_level =

View File

@ -422,7 +422,7 @@ public:
if (data)
{
std::vector<u8> file_data_enc(Common::AlignUp(data->size(), BLOCK_SZ));
std::copy(data->cbegin(), data->cend(), file_data_enc.begin());
std::ranges::copy(*data, file_data_enc.begin());
m_iosc.Encrypt(IOS::HLE::IOSC::HANDLE_SD_KEY, file_hdr.iv.data(), file_data_enc.data(),
file_data_enc.size(), file_data_enc.data(), IOS::PID_ES);
if (!m_file.WriteBytes(file_data_enc.data(), file_data_enc.size()))

View File

@ -70,7 +70,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
std::array<CameraPoint, CameraLogic::NUM_POINTS> camera_points;
std::transform(leds.begin(), leds.end(), camera_points.begin(), [&](const Vec3& v) {
std::ranges::transform(leds, camera_points.begin(), [&](const Vec3& v) {
const auto point = camera_view * Vec4(v, 1.0);
// Check if LED is behind camera.

View File

@ -452,7 +452,7 @@ bool Wiimote::ProcessReadDataRequest()
reply.address = Common::swap16(m_read_request.address);
// Pre-fill with zeros in case of read-error or read < 16-bytes:
std::fill(std::begin(reply.data), std::end(reply.data), 0x00);
std::ranges::fill(reply.data, 0x00);
ErrorCode error_code = ErrorCode::Success;

View File

@ -613,8 +613,7 @@ void WiimoteScanner::SetScanMode(WiimoteScanMode scan_mode)
bool WiimoteScanner::IsReady() const
{
std::lock_guard lg(m_backends_mutex);
return std::any_of(m_backends.begin(), m_backends.end(),
[](const auto& backend) { return backend->IsReady(); });
return std::ranges::any_of(m_backends, [](const auto& backend) { return backend->IsReady(); });
}
static void CheckForDisconnectedWiimotes()

View File

@ -420,8 +420,8 @@ ControllerEmu::ControlGroup* HotkeyManager::GetHotkeyGroup(HotkeyGroup group) co
int HotkeyManager::FindGroupByID(int id) const
{
const auto i = std::find_if(s_groups_info.begin(), s_groups_info.end(),
[id](const auto& entry) { return entry.last >= id; });
const auto i =
std::ranges::find_if(s_groups_info, [id](const auto& entry) { return entry.last >= id; });
return static_cast<int>(std::distance(s_groups_info.begin(), i));
}

View File

@ -33,14 +33,14 @@ std::optional<IPCReply> ShaDevice::Open(const OpenRequest& request)
static void ConvertContext(const ShaDevice::ShaContext& src, mbedtls_sha1_context* dest)
{
std::copy(std::begin(src.length), std::end(src.length), std::begin(dest->total));
std::copy(std::begin(src.states), std::end(src.states), std::begin(dest->state));
std::ranges::copy(src.length, std::begin(dest->total));
std::ranges::copy(src.states, std::begin(dest->state));
}
static void ConvertContext(const mbedtls_sha1_context& src, ShaDevice::ShaContext* dest)
{
std::copy(std::begin(src.total), std::end(src.total), std::begin(dest->length));
std::copy(std::begin(src.state), std::end(src.state), std::begin(dest->states));
std::ranges::copy(src.total, std::begin(dest->length));
std::ranges::copy(src.state, std::begin(dest->states));
}
HLE::ReturnCode ShaDevice::ProcessShaCommand(ShaIoctlv command, const IOCtlVRequest& request)

View File

@ -98,8 +98,8 @@ bool IOCtlVRequest::HasNumberOfValidVectors(const size_t in_count, const size_t
return false;
auto IsValidVector = [](const auto& vector) { return vector.size == 0 || vector.address != 0; };
return std::all_of(in_vectors.begin(), in_vectors.end(), IsValidVector) &&
std::all_of(io_vectors.begin(), io_vectors.end(), IsValidVector);
return std::ranges::all_of(in_vectors, IsValidVector) &&
std::ranges::all_of(io_vectors, IsValidVector);
}
void IOCtlRequest::Log(std::string_view device_name, Common::Log::LogType type,

View File

@ -527,14 +527,13 @@ void ESDevice::DoState(PointerWrap& p)
ESDevice::ContextArray::iterator ESDevice::FindActiveContext(s32 fd)
{
return std::find_if(m_contexts.begin(), m_contexts.end(),
[fd](const auto& context) { return context.ipc_fd == fd && context.active; });
return std::ranges::find_if(
m_contexts, [fd](const auto& context) { return context.ipc_fd == fd && context.active; });
}
ESDevice::ContextArray::iterator ESDevice::FindInactiveContext()
{
return std::find_if(m_contexts.begin(), m_contexts.end(),
[](const auto& context) { return !context.active; });
return std::ranges::find_if(m_contexts, [](const auto& context) { return !context.active; });
}
std::optional<IPCReply> ESDevice::Open(const OpenRequest& request)

View File

@ -302,7 +302,7 @@ std::string TMDReader::GetGameID() const
std::memcpy(game_id, m_bytes.data() + offsetof(TMDHeader, title_id) + 4, 4);
std::memcpy(game_id + 4, m_bytes.data() + offsetof(TMDHeader, group_id), 2);
if (std::all_of(std::begin(game_id), std::end(game_id), Common::IsPrintableCharacter))
if (std::ranges::all_of(game_id, Common::IsPrintableCharacter))
return std::string(game_id, sizeof(game_id));
return fmt::format("{:016x}", GetTitleId());
@ -535,7 +535,7 @@ HLE::ReturnCode TicketReader::Unpersonalise(HLE::IOSC& iosc)
sizeof(Ticket::title_key), key.data(), PID_ES);
// Finally, IOS copies the decrypted title key back to the ticket buffer.
if (ret == IPC_SUCCESS)
std::copy(key.cbegin(), key.cend(), ticket_begin + offsetof(Ticket, title_key));
std::ranges::copy(key, ticket_begin + offsetof(Ticket, title_key));
return ret;
}
@ -575,8 +575,8 @@ SharedContentMap::~SharedContentMap() = default;
std::optional<std::string>
SharedContentMap::GetFilenameFromSHA1(const std::array<u8, 20>& sha1) const
{
const auto it = std::find_if(m_entries.begin(), m_entries.end(),
[&sha1](const auto& entry) { return entry.sha1 == sha1; });
const auto it =
std::ranges::find_if(m_entries, [&sha1](const auto& entry) { return entry.sha1 == sha1; });
if (it == m_entries.end())
return {};
@ -602,7 +602,7 @@ std::string SharedContentMap::AddSharedContent(const std::array<u8, 20>& sha1)
const std::string id = fmt::format("{:08x}", m_last_id);
Entry entry;
std::copy(id.cbegin(), id.cend(), entry.id.begin());
std::ranges::copy(id, entry.id.begin());
entry.sha1 = sha1;
m_entries.push_back(entry);
@ -672,8 +672,8 @@ UIDSys::UIDSys(HLE::FSCore& fs_core) : m_fs{fs_core.GetFS()}
u32 UIDSys::GetUIDFromTitle(u64 title_id) const
{
const auto it = std::find_if(m_entries.begin(), m_entries.end(),
[title_id](const auto& entry) { return entry.second == title_id; });
const auto it = std::ranges::find_if(
m_entries, [title_id](const auto& entry) { return entry.second == title_id; });
return (it == m_entries.end()) ? 0 : it->first;
}
@ -726,7 +726,7 @@ CertReader::CertReader(std::vector<u8>&& bytes) : SignedBlobReader(std::move(byt
{SignatureType::ECC, PublicKeyType::ECC, sizeof(CertECC)},
}};
const auto info = std::find_if(types.cbegin(), types.cend(), [this](const CertStructInfo& entry) {
const auto info = std::ranges::find_if(types, [this](const CertStructInfo& entry) {
return m_bytes.size() >= std::get<2>(entry) && std::get<0>(entry) == GetSignatureType() &&
std::get<1>(entry) == GetPublicKeyType();
});

View File

@ -139,7 +139,7 @@ ReturnCode ESCore::VerifySign(const std::vector<u8>& hash, const std::vector<u8>
if (certs.empty())
return ES_EINVAL;
const auto ap_iterator = std::find_if(certs.begin(), certs.end(), [](const auto& entry) {
const auto ap_iterator = std::ranges::find_if(certs, [](const auto& entry) {
return entry.first.length() > 2 && entry.first.compare(0, 2, "AP") == 0;
});
if (ap_iterator == certs.end())

View File

@ -79,8 +79,8 @@ static bool IsValidPartOfTitleID(const std::string& string)
{
if (string.length() != 8)
return false;
return std::all_of(string.begin(), string.end(),
[](const auto character) { return std::isxdigit(character) != 0; });
return std::ranges::all_of(string,
[](const auto character) { return std::isxdigit(character) != 0; });
}
static std::vector<u64> GetTitlesInTitleOrImport(FS::FileSystem* fs, const std::string& titles_dir)
@ -189,29 +189,32 @@ ESCore::GetStoredContentsFromTMD(const ES::TMDReader& tmd,
std::vector<ES::Content> stored_contents;
std::copy_if(contents.begin(), contents.end(), std::back_inserter(stored_contents),
[this, &tmd, check_content_hashes](const ES::Content& content) {
const auto fs = m_ios.GetFS();
std::ranges::copy_if(contents, std::back_inserter(stored_contents),
[this, &tmd, check_content_hashes](const ES::Content& content) {
const auto fs = m_ios.GetFS();
const std::string path = GetContentPath(tmd.GetTitleId(), content);
if (path.empty())
return false;
const std::string path = GetContentPath(tmd.GetTitleId(), content);
if (path.empty())
return false;
// Check whether the content file exists.
const auto file = fs->OpenFile(PID_KERNEL, PID_KERNEL, path, FS::Mode::Read);
if (!file.Succeeded())
return false;
// Check whether the content file exists.
const auto file =
fs->OpenFile(PID_KERNEL, PID_KERNEL, path, FS::Mode::Read);
if (!file.Succeeded())
return false;
// If content hash checks are disabled, all we have to do is check for existence.
if (check_content_hashes == CheckContentHashes::No)
return true;
// If content hash checks are disabled, all we have to do is check for
// existence.
if (check_content_hashes == CheckContentHashes::No)
return true;
// Otherwise, check whether the installed content SHA1 matches the expected hash.
std::vector<u8> content_data(file->GetStatus()->size);
if (!file->Read(content_data.data(), content_data.size()))
return false;
return Common::SHA1::CalculateDigest(content_data) == content.sha1;
});
// Otherwise, check whether the installed content SHA1 matches the expected
// hash.
std::vector<u8> content_data(file->GetStatus()->size);
if (!file->Read(content_data.data(), content_data.size()))
return false;
return Common::SHA1::CalculateDigest(content_data) == content.sha1;
});
return stored_contents;
}

View File

@ -464,7 +464,7 @@ static bool HasAllRequiredContents(Kernel& ios, const ES::TMDReader& tmd)
const u64 title_id = tmd.GetTitleId();
const std::vector<ES::Content> contents = tmd.GetContents();
const ES::SharedContentMap shared_content_map{ios.GetFSCore()};
return std::all_of(contents.cbegin(), contents.cend(), [&](const ES::Content& content) {
return std::ranges::all_of(contents, [&](const ES::Content& content) {
if (content.IsOptional())
return true;
@ -817,7 +817,7 @@ ReturnCode ESCore::ExportContentData(Context& context, u32 content_fd, u8* data,
if (encrypt_ret != IPC_SUCCESS)
return encrypt_ret;
std::copy(output.cbegin(), output.cend(), data);
std::ranges::copy(output, data);
return IPC_SUCCESS;
}
@ -878,7 +878,7 @@ ReturnCode ESCore::DeleteSharedContent(const std::array<u8, 20>& sha1) const
// Check whether the shared content is used by a system title.
const std::vector<u64> titles = GetInstalledTitles();
const bool is_used_by_system_title = std::any_of(titles.begin(), titles.end(), [&](u64 id) {
const bool is_used_by_system_title = std::ranges::any_of(titles, [&](u64 id) {
if (!ES::IsTitleType(id, ES::TitleType::System))
return false;
@ -887,8 +887,8 @@ ReturnCode ESCore::DeleteSharedContent(const std::array<u8, 20>& sha1) const
return true;
const auto contents = tmd.GetContents();
return std::any_of(contents.begin(), contents.end(),
[&sha1](const auto& content) { return content.sha1 == sha1; });
return std::ranges::any_of(contents,
[&sha1](const auto& content) { return content.sha1 == sha1; });
});
// Any shared content used by a system title cannot be deleted.

View File

@ -147,7 +147,7 @@ ReturnCode ESCore::GetTicketFromView(const u8* ticket_view, u8* ticket, u32* tic
return ES_EACCES;
}
std::copy(ticket_bytes.begin(), ticket_bytes.end(), ticket);
std::ranges::copy(ticket_bytes, ticket);
return IPC_SUCCESS;
}

View File

@ -26,7 +26,7 @@ bool IsValidNonRootPath(std::string_view path)
bool IsValidFilename(std::string_view filename)
{
return filename.length() <= MaxFilenameLength &&
!std::any_of(filename.begin(), filename.end(), [](char c) { return c == '/'; });
!std::ranges::any_of(filename, [](char c) { return c == '/'; });
}
SplitPathResult SplitPathAndBasename(std::string_view path)

View File

@ -143,7 +143,7 @@ enum class FileLookupMode
static SystemTimers::TimeBaseTick EstimateFileLookupTicks(const std::string& path,
FileLookupMode mode)
{
const size_t number_of_path_components = std::count(path.cbegin(), path.cend(), '/');
const size_t number_of_path_components = std::ranges::count(path, '/');
if (number_of_path_components == 0)
return 0_tbticks;

View File

@ -254,8 +254,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
for (const std::string& component : SplitString(std::string(path.substr(1)), '/'))
{
complete_path += '/' + component;
const auto next =
std::find_if(entry->children.begin(), entry->children.end(), GetNamePredicate(component));
const auto next = std::ranges::find_if(entry->children, GetNamePredicate(component));
if (next != entry->children.end())
{
entry = &*next;
@ -461,13 +460,12 @@ ResultCode HostFileSystem::Format(Uid uid)
ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::string& path,
FileAttribute attr, Modes modes, bool is_file)
{
if (!IsValidNonRootPath(path) ||
!std::all_of(path.begin(), path.end(), Common::IsPrintableCharacter))
if (!IsValidNonRootPath(path) || !std::ranges::all_of(path, Common::IsPrintableCharacter))
{
return ResultCode::Invalid;
}
if (!is_file && std::count(path.begin(), path.end(), '/') > int(MaxPathDepth))
if (!is_file && std::ranges::count(path, '/') > int(MaxPathDepth))
return ResultCode::TooManyPathComponents;
const auto split_path = SplitPathAndBasename(path);
@ -516,14 +514,14 @@ ResultCode HostFileSystem::CreateDirectory(Uid uid, Gid gid, const std::string&
bool HostFileSystem::IsFileOpened(const std::string& path) const
{
return std::any_of(m_handles.begin(), m_handles.end(), [&path](const Handle& handle) {
return std::ranges::any_of(m_handles, [&path](const Handle& handle) {
return handle.opened && handle.wii_path == path;
});
}
bool HostFileSystem::IsDirectoryInUse(const std::string& path) const
{
return std::any_of(m_handles.begin(), m_handles.end(), [&path](const Handle& handle) {
return std::ranges::any_of(m_handles, [&path](const Handle& handle) {
return handle.opened && handle.wii_path.starts_with(path);
});
}
@ -553,8 +551,7 @@ ResultCode HostFileSystem::Delete(Uid uid, Gid gid, const std::string& path)
else
return ResultCode::InUse;
const auto it = std::find_if(parent->children.begin(), parent->children.end(),
GetNamePredicate(split_path.file_name));
const auto it = std::ranges::find_if(parent->children, GetNamePredicate(split_path.file_name));
if (it != parent->children.end())
parent->children.erase(it);
SaveFst();
@ -643,8 +640,8 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path,
new_entry->name = split_new_path.file_name;
// Finally, remove the child from the old parent and move it to the new parent.
const auto it = std::find_if(old_parent->children.begin(), old_parent->children.end(),
GetNamePredicate(split_old_path.file_name));
const auto it =
std::ranges::find_if(old_parent->children, GetNamePredicate(split_old_path.file_name));
if (it != old_parent->children.end())
{
new_entry->data = it->data;
@ -694,17 +691,17 @@ Result<std::vector<std::string>> HostFileSystem::ReadDirectory(Uid uid, Gid gid,
// Now sort in reverse order because Nintendo traverses a linked list
// in which new elements are inserted at the front.
std::sort(host_entry.children.begin(), host_entry.children.end(),
[&get_key](const File::FSTEntry& one, const File::FSTEntry& two) {
const int key1 = get_key(one.virtualName);
const int key2 = get_key(two.virtualName);
if (key1 != key2)
return key1 > key2;
std::ranges::sort(host_entry.children,
[&get_key](const File::FSTEntry& one, const File::FSTEntry& two) {
const int key1 = get_key(one.virtualName);
const int key2 = get_key(two.virtualName);
if (key1 != key2)
return key1 > key2;
// For files that are not in the FST, sort lexicographically to ensure that
// results are consistent no matter what the underlying filesystem is.
return one.virtualName > two.virtualName;
});
// For files that are not in the FST, sort lexicographically to ensure that
// results are consistent no matter what the underlying filesystem is.
return one.virtualName > two.virtualName;
});
std::vector<std::string> output;
for (const File::FSTEntry& child : host_entry.children)

View File

@ -207,8 +207,8 @@ Result<FileStatus> HostFileSystem::GetFileStatus(Fd fd)
HostFileSystem::Handle* HostFileSystem::AssignFreeHandle()
{
const auto it = std::find_if(m_handles.begin(), m_handles.end(),
[](const Handle& handle) { return !handle.opened; });
const auto it =
std::ranges::find_if(m_handles, [](const Handle& handle) { return !handle.opened; });
if (it == m_handles.end())
return nullptr;

View File

@ -105,9 +105,9 @@ constexpr u32 PLACEHOLDER = 0xDEADBEEF;
static bool SetupMemory(Memory::MemoryManager& memory, u64 ios_title_id, MemorySetupType setup_type)
{
auto target_imv = std::find_if(
GetMemoryValues().begin(), GetMemoryValues().end(),
[&](const MemoryValues& imv) { return imv.ios_number == (ios_title_id & 0xffff); });
auto target_imv = std::ranges::find_if(GetMemoryValues(), [&](const MemoryValues& imv) {
return imv.ios_number == (ios_title_id & 0xffff);
});
if (target_imv == GetMemoryValues().end())
{

View File

@ -551,7 +551,7 @@ void IOSC::Sign(u8* sig_out, u8* ap_cert_out, u64 title_id, const u8* data, u32
// Sign the data.
const auto data_digest = Common::SHA1::CalculateDigest(data, data_size);
const auto signature = Common::ec::Sign(ap_priv.data(), data_digest.data());
std::copy(signature.cbegin(), signature.cend(), sig_out);
std::ranges::copy(signature, sig_out);
}
void IOSC::LoadDefaultEntries()
@ -669,8 +669,7 @@ IOSC::KeyEntry::KeyEntry(ObjectType type_, ObjectSubType subtype_, std::vector<u
IOSC::KeyEntries::iterator IOSC::FindFreeEntry()
{
return std::find_if(m_key_entries.begin(), m_key_entries.end(),
[](const auto& entry) { return !entry.in_use; });
return std::ranges::find_if(m_key_entries, [](const auto& entry) { return !entry.in_use; });
}
IOSC::KeyEntry* IOSC::FindEntry(Handle handle)

View File

@ -58,8 +58,8 @@ bool WC24FriendList::CheckFriendList() const
bool WC24FriendList::DoesFriendExist(u64 friend_id) const
{
return std::any_of(m_data.friend_codes.cbegin(), m_data.friend_codes.cend(),
[&friend_id](const u64 v) { return v == friend_id; });
return std::ranges::any_of(m_data.friend_codes,
[&friend_id](const u64 v) { return v == friend_id; });
}
std::vector<u64> WC24FriendList::GetUnconfirmedFriends() const

View File

@ -62,8 +62,8 @@ u8 GetAreaCode(std::string_view area)
{"CHN", 6},
}};
const auto entry_pos = std::find_if(regions.cbegin(), regions.cend(),
[&area](const auto& entry) { return entry.first == area; });
const auto entry_pos =
std::ranges::find_if(regions, [&area](const auto& entry) { return entry.first == area; });
if (entry_pos != regions.end())
return entry_pos->second;
@ -79,8 +79,8 @@ HardwareModel GetHardwareModel(std::string_view model)
{"RVD", HardwareModel::RVD},
}};
const auto entry_pos = std::find_if(models.cbegin(), models.cend(),
[&model](const auto& entry) { return entry.first == model; });
const auto entry_pos =
std::ranges::find_if(models, [&model](const auto& entry) { return entry.first == model; });
if (entry_pos != models.cend())
return entry_pos->second;

View File

@ -1085,10 +1085,10 @@ void WiiSockMan::UpdatePollCommands()
std::vector<int> original_order(pfds.size());
std::iota(original_order.begin(), original_order.end(), 0);
// Select indices with valid fds
auto mid = std::partition(original_order.begin(), original_order.end(), [&](auto i) {
auto mid = std::ranges::partition(original_order, [&](auto i) {
return GetHostSocket(memory.Read_U32(pcmd.buffer_out + 0xc * i)) >= 0;
});
const auto n_valid = std::distance(original_order.begin(), mid);
const auto n_valid = std::distance(original_order.begin(), mid.begin());
// Move all the valid pollfds to the front of the vector
for (auto i = 0; i < n_valid; ++i)

View File

@ -51,8 +51,8 @@ BluetoothEmuDevice::BluetoothEmuDevice(EmulationKernel& ios, const std::string&
const bdaddr_t tmp_bd = {0x11, 0x02, 0x19, 0x79, 0, i};
// Previous records can be safely overwritten, since they are backed up
std::copy(tmp_bd.begin(), tmp_bd.end(), std::rbegin(bt_dinf.active[i].bdaddr));
std::copy(tmp_bd.begin(), tmp_bd.end(), std::rbegin(bt_dinf.registered[i].bdaddr));
std::ranges::copy(tmp_bd, std::rbegin(bt_dinf.active[i].bdaddr));
std::ranges::copy(tmp_bd, std::rbegin(bt_dinf.registered[i].bdaddr));
const auto& wm_name =
(i == WIIMOTE_BALANCE_BOARD) ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01";
@ -473,8 +473,8 @@ bool BluetoothEmuDevice::SendEventInquiryResponse()
static_assert(
sizeof(SHCIEventInquiryResult) - 2 + (num_responses * sizeof(hci_inquiry_response)) < 256);
const auto iter = std::find_if(m_wiimotes.begin(), m_wiimotes.end(),
std::mem_fn(&WiimoteDevice::IsInquiryScanEnabled));
const auto iter =
std::ranges::find_if(m_wiimotes, std::mem_fn(&WiimoteDevice::IsInquiryScanEnabled));
if (iter == m_wiimotes.end())
{
// No remotes are discoverable.

View File

@ -481,9 +481,9 @@ bool BluetoothRealDevice::SendHCIStoreLinkKeyCommand()
auto iterator = packet.begin() + sizeof(hci_cmd_hdr_t) + sizeof(hci_write_stored_link_key_cp);
for (const auto& entry : m_link_keys)
{
std::copy(entry.first.begin(), entry.first.end(), iterator);
std::ranges::copy(entry.first, iterator);
iterator += entry.first.size();
std::copy(entry.second.begin(), entry.second.end(), iterator);
std::ranges::copy(entry.second, iterator);
iterator += entry.second.size();
}
@ -597,7 +597,7 @@ void BluetoothRealDevice::LoadLinkKeys()
}
auto& mac = address.value();
std::reverse(mac.begin(), mac.end());
std::ranges::reverse(mac);
const std::string& key_string = pair.substr(index + 1);
linkkey_t key{};
@ -620,7 +620,7 @@ void BluetoothRealDevice::SaveLinkKeys()
{
bdaddr_t address;
// Reverse the address so that it is stored in the correct order in the config file
std::reverse_copy(entry.first.begin(), entry.first.end(), address.begin());
std::ranges::reverse_copy(entry.first, address.begin());
oss << Common::MacAddressToString(address);
oss << '=';
oss << std::hex;
@ -734,7 +734,7 @@ void BluetoothRealDevice::HandleBulkOrIntrTransfer(libusb_transfer* tr)
hci_link_key_notification_ep notification;
std::memcpy(&notification, tr->buffer + sizeof(hci_event_hdr_t), sizeof(notification));
linkkey_t key;
std::copy(std::begin(notification.key), std::end(notification.key), std::begin(key));
std::ranges::copy(notification.key, std::begin(key));
m_link_keys[notification.bdaddr] = key;
}
else if (event == HCI_EVENT_COMMAND_COMPL)

View File

@ -74,7 +74,7 @@ bool Device::HasClass(const u8 device_class) const
if (GetDeviceDescriptor().bDeviceClass == device_class)
return true;
const auto interfaces = GetInterfaces(0);
return std::any_of(interfaces.begin(), interfaces.end(), [device_class](const auto& interface) {
return std::ranges::any_of(interfaces, [device_class](const auto& interface) {
return interface.bInterfaceClass == device_class;
});
}

View File

@ -234,7 +234,7 @@ std::optional<IPCReply> OH0::RegisterClassChangeHook(const IOCtlVRequest& reques
bool OH0::HasDeviceWithVidPid(const u16 vid, const u16 pid) const
{
return std::any_of(m_devices.begin(), m_devices.end(), [=](const auto& device) {
return std::ranges::any_of(m_devices, [=](const auto& device) {
return device.second->GetVid() == vid && device.second->GetPid() == pid;
});
}

View File

@ -87,7 +87,7 @@ void V4GetUSStringMessage::OnTransferComplete(s32 return_value) const
auto& memory = system.GetMemory();
std::string message = memory.GetString(data_address);
std::replace_if(message.begin(), message.end(), std::not_fn(Common::IsPrintableCharacter), '?');
std::ranges::replace_if(message, std::not_fn(Common::IsPrintableCharacter), '?');
memory.CopyToEmu(data_address, message.c_str(), message.size());
TransferCommand::OnTransferComplete(return_value);
}

View File

@ -169,11 +169,10 @@ IPCReply USB_HIDv5::GetDeviceInfo(USBV5Device& device, const IOCtlRequest& reque
memory.CopyToEmu(request.buffer_out + 56, &config_descriptor, sizeof(config_descriptor));
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
auto it = std::find_if(interfaces.begin(), interfaces.end(),
[&](const USB::InterfaceDescriptor& interface) {
return interface.bInterfaceNumber == device.interface_number &&
interface.bAlternateSetting == alt_setting;
});
auto it = std::ranges::find_if(interfaces, [&](const USB::InterfaceDescriptor& interface) {
return interface.bInterfaceNumber == device.interface_number &&
interface.bAlternateSetting == alt_setting;
});
if (it == interfaces.end())
return IPCReply(IPC_EINVAL);
it->Swap();

View File

@ -152,11 +152,10 @@ IPCReply USB_VEN::GetDeviceInfo(USBV5Device& device, const IOCtlRequest& request
memory.CopyToEmu(request.buffer_out + 40, &config_descriptor, sizeof(config_descriptor));
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
auto it = std::find_if(interfaces.begin(), interfaces.end(),
[&](const USB::InterfaceDescriptor& interface) {
return interface.bInterfaceNumber == device.interface_number &&
interface.bAlternateSetting == alt_setting;
});
auto it = std::ranges::find_if(interfaces, [&](const USB::InterfaceDescriptor& interface) {
return interface.bInterfaceNumber == device.interface_number &&
interface.bAlternateSetting == alt_setting;
});
if (it == interfaces.end())
return IPCReply(IPC_EINVAL);
it->Swap();

View File

@ -380,9 +380,9 @@ bool IsEmulated(u32 major_version)
if (major_version == static_cast<u32>(Titles::BC & 0xffffffff))
return true;
return std::any_of(
ios_memory_values.begin(), ios_memory_values.end(),
[major_version](const MemoryValues& values) { return values.ios_number == major_version; });
return std::ranges::any_of(ios_memory_values, [major_version](const MemoryValues& values) {
return values.ios_number == major_version;
});
}
bool IsEmulated(u64 title_id)

View File

@ -372,8 +372,8 @@ s32 WFSSRVDevice::Rename(std::string source, std::string dest) const
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_RENAME: {} to {}", source, dest);
const bool opened = std::any_of(m_fds.begin(), m_fds.end(),
[&](const auto& fd) { return fd.in_use && fd.path == source; });
const bool opened =
std::ranges::any_of(m_fds, [&](const auto& fd) { return fd.in_use && fd.path == source; });
if (opened)
return WFS_FILE_IS_OPENED;

View File

@ -93,7 +93,7 @@ static std::array<u8, 20> ConvertGitRevisionToBytes(const std::string& revision)
{
std::array<u8, 20> revision_bytes{};
if (revision.size() % 2 == 0 && std::all_of(revision.begin(), revision.end(), ::isxdigit))
if (revision.size() % 2 == 0 && std::ranges::all_of(revision, ::isxdigit))
{
// The revision string normally contains a git commit hash,
// which is 40 hexadecimal digits long. In DTM files, each pair of
@ -1100,7 +1100,7 @@ void MovieManager::LoadInput(const std::string& movie_path)
"read-only mode off. Otherwise you'll probably get a desync.",
byte_offset, byte_offset);
std::copy(movInput.begin(), movInput.end(), m_temp_input.begin());
std::ranges::copy(movInput, m_temp_input.begin());
}
else
{

View File

@ -1536,9 +1536,8 @@ void NetPlayClient::DisplayPlayersPing()
u32 NetPlayClient::GetPlayersMaxPing() const
{
return std::max_element(
m_players.begin(), m_players.end(),
[](const auto& a, const auto& b) { return a.second.ping < b.second.ping; })
return std::ranges::max_element(
m_players, [](const auto& a, const auto& b) { return a.second.ping < b.second.ping; })
->second.ping;
}
@ -2407,10 +2406,8 @@ bool NetPlayClient::IsFirstInGamePad(int ingame_pad) const
static int CountLocalPads(const PadMappingArray& pad_map, const PlayerId& local_player_pid)
{
return static_cast<int>(
std::count_if(pad_map.begin(), pad_map.end(), [&local_player_pid](const auto& mapping) {
return mapping == local_player_pid;
}));
return static_cast<int>(std::ranges::count_if(
pad_map, [&local_player_pid](const auto& mapping) { return mapping == local_player_pid; }));
}
int NetPlayClient::NumLocalPads() const
@ -2484,8 +2481,8 @@ bool NetPlayClient::PlayerHasControllerMapped(const PlayerId pid) const
{
const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; };
return std::any_of(m_pad_map.begin(), m_pad_map.end(), mapping_matches_player_id) ||
std::any_of(m_wiimote_map.begin(), m_wiimote_map.end(), mapping_matches_player_id);
return std::ranges::any_of(m_pad_map, mapping_matches_player_id) ||
std::ranges::any_of(m_wiimote_map, mapping_matches_player_id);
}
bool NetPlayClient::IsLocalPlayer(const PlayerId pid) const
@ -2541,7 +2538,7 @@ bool NetPlayClient::DoAllPlayersHaveGame()
{
std::lock_guard lkp(m_crit.players);
return std::all_of(std::begin(m_players), std::end(m_players), [](auto entry) {
return std::ranges::all_of(m_players, [](auto entry) {
return entry.second.game_status == SyncIdentifierComparison::SameGame;
});
}

View File

@ -237,7 +237,7 @@ static bool DecompressPacketIntoFolderInternal(sf::Packet& packet, const std::st
if (name.find('\\') != std::string::npos)
return false;
#endif
if (std::all_of(name.begin(), name.end(), [](char c) { return c == '.'; }))
if (std::ranges::all_of(name, [](char c) { return c == '.'; }))
return false;
bool is_folder;

View File

@ -1058,14 +1058,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
{
// we have all records for this frame
if (!std::all_of(timebases.begin(), timebases.end(), [&](std::pair<PlayerId, u64> pair) {
if (!std::ranges::all_of(timebases, [&](std::pair<PlayerId, u64> pair) {
return pair.second == timebases[0].second;
}))
{
int pid_to_blame = 0;
for (auto pair : timebases)
{
if (std::all_of(timebases.begin(), timebases.end(), [&](std::pair<PlayerId, u64> other) {
if (std::ranges::all_of(timebases, [&](std::pair<PlayerId, u64> other) {
return other.first == pair.first || other.second != pair.second;
}))
{
@ -1464,14 +1464,12 @@ bool NetPlayServer::SetupNetSettings()
bool NetPlayServer::DoAllPlayersHaveIPLDump() const
{
return std::all_of(m_players.begin(), m_players.end(),
[](const auto& p) { return p.second.has_ipl_dump; });
return std::ranges::all_of(m_players, [](const auto& p) { return p.second.has_ipl_dump; });
}
bool NetPlayServer::DoAllPlayersHaveHardwareFMA() const
{
return std::all_of(m_players.begin(), m_players.end(),
[](const auto& p) { return p.second.has_hardware_fma; });
return std::ranges::all_of(m_players, [](const auto& p) { return p.second.has_hardware_fma; });
}
struct SaveSyncInfo
@ -2222,8 +2220,8 @@ bool NetPlayServer::PlayerHasControllerMapped(const PlayerId pid) const
{
const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; };
return std::any_of(m_pad_map.begin(), m_pad_map.end(), mapping_matches_player_id) ||
std::any_of(m_wiimote_map.begin(), m_wiimote_map.end(), mapping_matches_player_id);
return std::ranges::any_of(m_pad_map, mapping_matches_player_id) ||
std::ranges::any_of(m_wiimote_map, mapping_matches_player_id);
}
void NetPlayServer::AssignNewUserAPad(const Client& player)

View File

@ -77,7 +77,7 @@ std::optional<PatchEntry> DeserializeLine(std::string line)
entry.conditional = true;
}
const auto iter = std::find(s_patch_type_strings.begin(), s_patch_type_strings.end(), items[1]);
const auto iter = std::ranges::find(s_patch_type_strings, items[1]);
if (iter == s_patch_type_strings.end())
return std::nullopt;
entry.type = static_cast<PatchType>(std::distance(s_patch_type_strings.begin(), iter));

View File

@ -49,8 +49,8 @@ const TBreakPoint* BreakPoints::GetBreakpoint(u32 address) const
const TBreakPoint* BreakPoints::GetRegularBreakpoint(u32 address) const
{
auto bp = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp_) { return bp_.address == address; });
auto bp = std::ranges::find_if(m_breakpoints,
[address](const auto& bp_) { return bp_.address == address; });
if (bp == m_breakpoints.end())
return nullptr;
@ -127,8 +127,8 @@ void BreakPoints::Add(u32 address, bool break_on_hit, bool log_on_hit,
{
// Check for existing breakpoint, and overwrite with new info.
// This is assuming we usually want the new breakpoint over an old one.
auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp) { return bp.address == address; });
auto iter = std::ranges::find_if(m_breakpoints,
[address](const auto& bp) { return bp.address == address; });
TBreakPoint bp; // breakpoint settings
bp.is_enabled = true;
@ -176,8 +176,8 @@ bool BreakPoints::ToggleBreakPoint(u32 address)
bool BreakPoints::ToggleEnable(u32 address)
{
auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp) { return bp.address == address; });
auto iter = std::ranges::find_if(m_breakpoints,
[address](const auto& bp) { return bp.address == address; });
if (iter == m_breakpoints.end())
return false;
@ -188,8 +188,8 @@ bool BreakPoints::ToggleEnable(u32 address)
bool BreakPoints::Remove(u32 address)
{
const auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp) { return bp.address == address; });
const auto iter = std::ranges::find_if(
m_breakpoints, [address](const auto& bp) { return bp.address == address; });
if (iter == m_breakpoints.cend())
return false;
@ -293,9 +293,8 @@ void MemChecks::Add(TMemCheck memory_check)
// Check for existing breakpoint, and overwrite with new info.
// This is assuming we usually want the new breakpoint over an old one.
const u32 address = memory_check.start_address;
auto old_mem_check =
std::find_if(m_mem_checks.begin(), m_mem_checks.end(),
[address](const auto& check) { return check.start_address == address; });
auto old_mem_check = std::ranges::find_if(
m_mem_checks, [address](const auto& check) { return check.start_address == address; });
if (old_mem_check != m_mem_checks.end())
{
memory_check.is_enabled = old_mem_check->is_enabled; // Preserve enabled status
@ -315,8 +314,8 @@ void MemChecks::Add(TMemCheck memory_check)
bool MemChecks::ToggleEnable(u32 address)
{
auto iter = std::find_if(m_mem_checks.begin(), m_mem_checks.end(),
[address](const auto& bp) { return bp.start_address == address; });
auto iter = std::ranges::find_if(
m_mem_checks, [address](const auto& bp) { return bp.start_address == address; });
if (iter == m_mem_checks.end())
return false;
@ -327,9 +326,8 @@ bool MemChecks::ToggleEnable(u32 address)
bool MemChecks::Remove(u32 address)
{
const auto iter =
std::find_if(m_mem_checks.cbegin(), m_mem_checks.cend(),
[address](const auto& check) { return check.start_address == address; });
const auto iter = std::ranges::find_if(
m_mem_checks, [address](const auto& check) { return check.start_address == address; });
if (iter == m_mem_checks.cend())
return false;
@ -352,10 +350,9 @@ void MemChecks::Clear()
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
{
const auto iter =
std::find_if(m_mem_checks.begin(), m_mem_checks.end(), [address, size](const auto& mc) {
return mc.end_address >= address && address + size - 1 >= mc.start_address;
});
const auto iter = std::ranges::find_if(m_mem_checks, [address, size](const auto& mc) {
return mc.end_address >= address && address + size - 1 >= mc.start_address;
});
// None found
if (iter == m_mem_checks.cend())
@ -372,7 +369,7 @@ bool MemChecks::OverlapsMemcheck(u32 address, u32 length) const
const u32 page_end_suffix = length - 1;
const u32 page_end_address = address | page_end_suffix;
return std::any_of(m_mem_checks.cbegin(), m_mem_checks.cend(), [&](const auto& mc) {
return std::ranges::any_of(m_mem_checks, [&](const auto& mc) {
return ((mc.start_address | page_end_suffix) == page_end_address ||
(mc.end_address | page_end_suffix) == page_end_address) ||
((mc.start_address | page_end_suffix) < page_end_address &&

View File

@ -136,15 +136,14 @@ static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
if (!std::isnan(num))
{
u32 address = static_cast<u32>(num);
return std::any_of(stack.begin(), stack.end(),
[address](const auto& s) { return s.vAddress == address; });
return std::ranges::any_of(stack, [address](const auto& s) { return s.vAddress == address; });
}
const char* cstr = expr_get_str(&vec_nth(args, 0));
if (cstr != nullptr)
{
return std::any_of(stack.begin(), stack.end(),
[cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; });
return std::ranges::any_of(
stack, [cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; });
}
return 0;

View File

@ -369,10 +369,8 @@ RCForkGuard RegCache::Fork()
void RegCache::Discard(BitSet32 pregs)
{
ASSERT_MSG(
DYNA_REC,
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }),
"Someone forgot to unlock a X64 reg");
ASSERT_MSG(DYNA_REC, std::ranges::none_of(m_xregs, [](const auto& x) { return x.IsLocked(); }),
"Someone forgot to unlock a X64 reg");
for (preg_t i : pregs)
{
@ -393,10 +391,8 @@ void RegCache::Discard(BitSet32 pregs)
void RegCache::Flush(BitSet32 pregs)
{
ASSERT_MSG(
DYNA_REC,
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }),
"Someone forgot to unlock a X64 reg");
ASSERT_MSG(DYNA_REC, std::ranges::none_of(m_xregs, [](const auto& x) { return x.IsLocked(); }),
"Someone forgot to unlock a X64 reg");
for (preg_t i : pregs)
{
@ -458,8 +454,8 @@ void RegCache::Commit()
bool RegCache::IsAllUnlocked() const
{
return std::none_of(m_regs.begin(), m_regs.end(), [](const auto& r) { return r.IsLocked(); }) &&
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }) &&
return std::ranges::none_of(m_regs, [](const auto& r) { return r.IsLocked(); }) &&
std::ranges::none_of(m_xregs, [](const auto& x) { return x.IsLocked(); }) &&
!IsAnyConstraintActive();
}
@ -525,10 +521,11 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty)
}
ASSERT_MSG(DYNA_REC,
std::none_of(m_regs.begin(), m_regs.end(),
[xr](const auto& r) {
return r.Location().has_value() && r.Location()->IsSimpleReg(xr);
}),
std::ranges::none_of(m_regs,
[xr](const auto& r) {
return r.Location().has_value() &&
r.Location()->IsSimpleReg(xr);
}),
"Xreg {} already bound", Common::ToUnderlying(xr));
m_regs[i].SetBoundTo(xr);
@ -753,6 +750,5 @@ void RegCache::Realize(preg_t preg)
bool RegCache::IsAnyConstraintActive() const
{
return std::any_of(m_constraints.begin(), m_constraints.end(),
[](const auto& c) { return c.IsActive(); });
return std::ranges::any_of(m_constraints, [](const auto& c) { return c.IsActive(); });
}

View File

@ -112,7 +112,7 @@ JitBase::~JitBase()
bool JitBase::DoesConfigNeedRefresh()
{
return std::any_of(JIT_SETTINGS.begin(), JIT_SETTINGS.end(), [this](const auto& pair) {
return std::ranges::any_of(JIT_SETTINGS, [this](const auto& pair) {
return this->*pair.first != Config::Get(*pair.second);
});
}

View File

@ -191,7 +191,7 @@ static void AnalyzeFunction2(PPCSymbolDB* func_db, Common::Symbol* func)
{
u32 flags = func->flags;
bool nonleafcall = std::any_of(func->calls.begin(), func->calls.end(), [&](const auto& call) {
bool nonleafcall = std::ranges::any_of(func->calls, [&](const auto& call) {
const Common::Symbol* const called_func = func_db->GetSymbolFromAddr(call.function);
return called_func && (called_func->flags & Common::FFLAG_LEAF) == 0;
});

View File

@ -100,9 +100,9 @@ void Cache::Reset()
valid.fill(0);
plru.fill(0);
modified.fill(0);
std::fill(lookup_table.begin(), lookup_table.end(), 0xFF);
std::fill(lookup_table_ex.begin(), lookup_table_ex.end(), 0xFF);
std::fill(lookup_table_vmem.begin(), lookup_table_vmem.end(), 0xFF);
std::ranges::fill(lookup_table, 0xFF);
std::ranges::fill(lookup_table_ex, 0xFF);
std::ranges::fill(lookup_table_vmem, 0xFF);
}
void InstructionCache::Reset(JitInterface& jit_interface)

View File

@ -695,8 +695,7 @@ void PrintInstructionRunCounts()
const GekkoOPInfo& info = s_tables.all_instructions[i];
temp[i] = std::make_pair(info.opname, info.stats->run_count);
}
std::sort(temp.begin(), temp.end(),
[](const OpInfo& a, const OpInfo& b) { return a.second > b.second; });
std::ranges::sort(temp, [](const OpInfo& a, const OpInfo& b) { return a.second > b.second; });
for (auto& inst : temp)
{

View File

@ -128,10 +128,10 @@ void PowerPCManager::DoState(PointerWrap& p)
void PowerPCManager::ResetRegisters()
{
std::fill(std::begin(m_ppc_state.ps), std::end(m_ppc_state.ps), PairedSingle{});
std::fill(std::begin(m_ppc_state.sr), std::end(m_ppc_state.sr), 0U);
std::fill(std::begin(m_ppc_state.gpr), std::end(m_ppc_state.gpr), 0U);
std::fill(std::begin(m_ppc_state.spr), std::end(m_ppc_state.spr), 0U);
std::ranges::fill(m_ppc_state.ps, PairedSingle{});
std::ranges::fill(m_ppc_state.sr, 0U);
std::ranges::fill(m_ppc_state.gpr, 0U);
std::ranges::fill(m_ppc_state.spr, 0U);
// Gamecube:
// 0x00080200 = lonestar 2.0

View File

@ -261,8 +261,8 @@ static int GetEmptySlot(const std::vector<SlotWithTimestamp>& used_slots)
{
for (int i = 1; i <= (int)NUM_STATES; i++)
{
const auto it = std::find_if(used_slots.begin(), used_slots.end(),
[i](const SlotWithTimestamp& slot) { return slot.slot == i; });
const auto it = std::ranges::find_if(
used_slots, [i](const SlotWithTimestamp& slot) { return slot.slot == i; });
if (it == used_slots.end())
return i;
}
@ -1000,7 +1000,7 @@ void LoadLastSaved(Core::System& system, int i)
return;
}
std::stable_sort(used_slots.begin(), used_slots.end(), CompareTimestamp);
std::ranges::stable_sort(used_slots, CompareTimestamp);
Load(system, (used_slots.end() - i)->slot);
}
@ -1016,7 +1016,7 @@ void SaveFirstSaved(Core::System& system)
}
// overwrite the oldest state
std::stable_sort(used_slots.begin(), used_slots.end(), CompareTimestamp);
std::ranges::stable_sort(used_slots, CompareTimestamp);
Save(system, used_slots.front().slot, true);
}

View File

@ -192,7 +192,7 @@ bool SysConf::Save() const
// Make sure the buffer size is 0x4000 bytes now and write the footer.
buffer.resize(SYSCONF_SIZE);
constexpr std::array<u8, 4> footer = {{'S', 'C', 'e', 'd'}};
std::copy(footer.cbegin(), footer.cend(), buffer.end() - footer.size());
std::ranges::copy(footer, buffer.end() - footer.size());
// Write the new data.
const std::string temp_file = "/tmp/SYSCONF";
@ -228,15 +228,15 @@ SysConf::Entry& SysConf::AddEntry(Entry&& entry)
SysConf::Entry* SysConf::GetEntry(std::string_view key)
{
const auto iterator = std::find_if(m_entries.begin(), m_entries.end(),
[&key](const auto& entry) { return entry.name == key; });
const auto iterator =
std::ranges::find_if(m_entries, [&key](const auto& entry) { return entry.name == key; });
return iterator != m_entries.end() ? &*iterator : nullptr;
}
const SysConf::Entry* SysConf::GetEntry(std::string_view key) const
{
const auto iterator = std::find_if(m_entries.begin(), m_entries.end(),
[&key](const auto& entry) { return entry.name == key; });
const auto iterator =
std::ranges::find_if(m_entries, [&key](const auto& entry) { return entry.name == key; });
return iterator != m_entries.end() ? &*iterator : nullptr;
}

View File

@ -86,8 +86,7 @@ static void LoadPatchSection(const Common::IniFile& ini)
static bool IsWC24Channel()
{
const auto& sconfig = SConfig::GetInstance();
const auto found =
std::find(s_wc24_channels.begin(), s_wc24_channels.end(), sconfig.GetTitleID());
const auto found = std::ranges::find(s_wc24_channels, sconfig.GetTitleID());
return found != s_wc24_channels.end();
}
@ -117,10 +116,9 @@ void Reload()
std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd)
{
const auto patch =
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
return p.source == source && p.is_kd == is_kd && p.enabled;
});
const auto patch = std::ranges::find_if(s_patches, [&source, &is_kd](const NetworkPatch& p) {
return p.source == source && p.is_kd == is_kd && p.enabled;
});
if (patch == s_patches.end())
return std::nullopt;

View File

@ -591,10 +591,10 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_
const UpdateResult import_result = [&]() {
for (const IOS::ES::Content& content : tmd.first.GetContents())
{
const bool is_already_installed = std::find_if(stored_contents.begin(), stored_contents.end(),
[&content](const auto& stored_content) {
return stored_content.id == content.id;
}) != stored_contents.end();
const bool is_already_installed =
std::ranges::find_if(stored_contents, [&content](const auto& stored_content) {
return stored_content.id == content.id;
}) != stored_contents.end();
// Do skip what is already installed on the NAND.
if (is_already_installed)
@ -751,7 +751,7 @@ UpdateResult DiscSystemUpdater::DoDiscUpdate()
const auto partitions = m_volume->GetPartitions();
const auto update_partition =
std::find_if(partitions.cbegin(), partitions.cend(), [&](const DiscIO::Partition& partition) {
std::ranges::find_if(partitions, [&](const DiscIO::Partition& partition) {
return m_volume->GetPartitionType(partition) == 1u;
});
@ -947,8 +947,8 @@ static NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios, bool repair)
}
const auto installed_contents = es.GetStoredContentsFromTMD(tmd);
const bool is_installed = std::any_of(installed_contents.begin(), installed_contents.end(),
[](const auto& content) { return !content.IsShared(); });
const bool is_installed = std::ranges::any_of(
installed_contents, [](const auto& content) { return !content.IsShared(); });
if (is_installed && installed_contents != tmd.GetContents() &&
(tmd.GetTitleFlags() & IOS::ES::TitleFlags::TITLE_TYPE_DATA) == 0)

View File

@ -84,8 +84,8 @@ SectorReader::~SectorReader()
const SectorReader::Cache* SectorReader::FindCacheLine(u64 block_num)
{
auto itr = std::find_if(m_cache.begin(), m_cache.end(),
[&](const Cache& entry) { return entry.Contains(block_num); });
auto itr =
std::ranges::find_if(m_cache, [&](const Cache& entry) { return entry.Contains(block_num); });
if (itr == m_cache.end())
return nullptr;

View File

@ -624,16 +624,15 @@ void DirectoryBlobReader::SetWiiRegionData(const std::vector<u8>& wii_region_dat
void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partitions)
{
std::sort(partitions.begin(), partitions.end(),
[](const PartitionWithType& lhs, const PartitionWithType& rhs) {
if (lhs.type == rhs.type)
return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
std::ranges::sort(partitions, [](const PartitionWithType& lhs, const PartitionWithType& rhs) {
if (lhs.type == rhs.type)
return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
// Ascending sort by partition type, except Update (1) comes before before Game (0)
return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
lhs.type < rhs.type :
lhs.type > rhs.type;
});
// Ascending sort by partition type, except Update (1) comes before before Game (0)
return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
lhs.type < rhs.type :
lhs.type > rhs.type;
});
u32 subtable_1_size = 0;
while (subtable_1_size < partitions.size() && subtable_1_size < 3 &&
@ -864,10 +863,8 @@ static std::vector<u8> ExtractNodeToVector(std::vector<FSTBuilderNode>* nodes, v
DirectoryBlobReader* blob)
{
std::vector<u8> data;
const auto it =
std::find_if(nodes->begin(), nodes->end(), [&userdata](const FSTBuilderNode& node) {
return node.m_user_data == userdata;
});
const auto it = std::ranges::find_if(
*nodes, [&userdata](const FSTBuilderNode& node) { return node.m_user_data == userdata; });
if (it == nodes->end() || !it->IsFile())
return data;
@ -1197,15 +1194,13 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<u8>* fst_data,
std::vector<FSTBuilderNode>& sorted_entries = *parent_entries;
// Sort for determinism
std::sort(sorted_entries.begin(), sorted_entries.end(),
[](const FSTBuilderNode& one, const FSTBuilderNode& two) {
std::string one_upper = one.m_filename;
std::string two_upper = two.m_filename;
Common::ToUpper(&one_upper);
Common::ToUpper(&two_upper);
return one_upper == two_upper ? one.m_filename < two.m_filename :
one_upper < two_upper;
});
std::ranges::sort(sorted_entries, [](const FSTBuilderNode& one, const FSTBuilderNode& two) {
std::string one_upper = one.m_filename;
std::string two_upper = two.m_filename;
Common::ToUpper(&one_upper);
Common::ToUpper(&two_upper);
return one_upper == two_upper ? one.m_filename < two.m_filename : one_upper < two_upper;
});
for (FSTBuilderNode& entry : sorted_entries)
{

View File

@ -39,8 +39,8 @@ std::string NameForPartitionType(u32 partition_type, bool include_prefix)
static_cast<char>((partition_type >> 16) & 0xFF),
static_cast<char>((partition_type >> 8) & 0xFF),
static_cast<char>(partition_type & 0xFF)};
if (std::all_of(type_as_game_id.cbegin(), type_as_game_id.cend(),
[](char c) { return std::isalnum(c, std::locale::classic()); }))
if (std::ranges::all_of(type_as_game_id,
[](char c) { return std::isalnum(c, std::locale::classic()); }))
{
return include_prefix ? "P-" + type_as_game_id : type_as_game_id;
}

View File

@ -240,9 +240,7 @@ bool NANDImporter::ExtractCertificates()
for (const PEMCertificate& certificate : certificates)
{
const auto search_result =
std::search(content_bytes.begin(), content_bytes.end(), certificate.search_bytes.begin(),
certificate.search_bytes.end());
const auto search_result = std::ranges::search(content_bytes, certificate.search_bytes).begin();
if (search_result == content_bytes.end())
{

View File

@ -146,8 +146,8 @@ std::optional<Disc> ParseString(std::string_view xml, std::string xml_path)
const std::string macro_id = macro_node.attribute("id").as_string();
for (auto& section : disc.m_sections)
{
auto option_to_clone = std::find_if(section.m_options.begin(), section.m_options.end(),
[&](const Option& o) { return o.m_id == macro_id; });
auto option_to_clone = std::ranges::find_if(
section.m_options, [&](const Option& o) { return o.m_id == macro_id; });
if (option_to_clone == section.m_options.end())
continue;
@ -305,8 +305,8 @@ std::vector<Patch> Disc::GeneratePatches(const std::string& game_id) const
const Choice& choice = option.m_choices[selected - 1];
for (const auto& patch_ref : choice.m_patch_references)
{
const auto patch = std::find_if(m_patches.begin(), m_patches.end(),
[&](const Patch& p) { return patch_ref.m_id == p.m_id; });
const auto patch = std::ranges::find_if(
m_patches, [&](const Patch& p) { return patch_ref.m_id == p.m_id; });
if (patch == m_patches.end())
continue;

View File

@ -104,7 +104,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
result.pop_back();
result.pop_back();
}
else if (std::all_of(element.begin(), element.end(), [](char c) { return c == '.'; }))
else if (std::ranges::all_of(element, [](char c) { return c == '.'; }))
{
// This is a triple, quadruple, etc. dot.
// Some file systems treat this as several 'up' path traversals, but Riivolution does not.
@ -366,7 +366,7 @@ static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTB
const size_t path_separator = path.find('/');
const bool is_file = path_separator == std::string_view::npos;
const std::string_view name = is_file ? path : path.substr(0, path_separator);
const auto it = std::find_if(fst->begin(), fst->end(), [&](const FSTBuilderNode& node) {
const auto it = std::ranges::find_if(*fst, [&](const FSTBuilderNode& node) {
return Common::CaseInsensitiveEquals(node.m_filename, name);
});

View File

@ -145,9 +145,7 @@ RedumpVerifier::DownloadStatus RedumpVerifier::DownloadDatfile(const std::string
const std::string system_not_available_message = "System \"" + system + "\" doesn't exist.";
const bool system_not_available_match =
result->end() != std::search(result->begin(), result->end(),
system_not_available_message.begin(),
system_not_available_message.end());
result->end() != std::ranges::search(*result, system_not_available_message).begin();
return system_not_available_match ? DownloadStatus::SystemNotAvailable : DownloadStatus::Fail;
}
@ -453,27 +451,23 @@ std::vector<Partition> VolumeVerifier::CheckPartitions()
types.emplace_back(*type);
}
if (std::find(types.cbegin(), types.cend(), PARTITION_UPDATE) == types.cend())
if (std::ranges::find(types, PARTITION_UPDATE) == types.cend())
AddProblem(Severity::Low, Common::GetStringT("The update partition is missing."));
const bool has_data_partition =
std::find(types.cbegin(), types.cend(), PARTITION_DATA) != types.cend();
const bool has_data_partition = std::ranges::find(types, PARTITION_DATA) != types.cend();
if (!m_is_datel && !has_data_partition)
AddProblem(Severity::High, Common::GetStringT("The data partition is missing."));
const bool has_channel_partition =
std::find(types.cbegin(), types.cend(), PARTITION_CHANNEL) != types.cend();
const bool has_channel_partition = std::ranges::find(types, PARTITION_CHANNEL) != types.cend();
if (ShouldHaveChannelPartition() && !has_channel_partition)
AddProblem(Severity::Medium, Common::GetStringT("The channel partition is missing."));
const bool has_install_partition =
std::find(types.cbegin(), types.cend(), PARTITION_INSTALL) != types.cend();
const bool has_install_partition = std::ranges::find(types, PARTITION_INSTALL) != types.cend();
if (ShouldHaveInstallPartition() && !has_install_partition)
AddProblem(Severity::High, Common::GetStringT("The install partition is missing."));
if (ShouldHaveMasterpiecePartitions() &&
types.cend() ==
std::find_if(types.cbegin(), types.cend(), [](u32 type) { return type >= 0xFF; }))
types.cend() == std::ranges::find_if(types, [](u32 type) { return type >= 0xFF; }))
{
// i18n: This string is referring to a game mode in Super Smash Bros. Brawl called Masterpieces
// where you play demos of NES/SNES/N64 games. Official translations:
@ -720,10 +714,9 @@ bool VolumeVerifier::ShouldHaveChannelPartition() const
"RFNE01", "RFNJ01", "RFNK01", "RFNP01", "RFNW01", "RFPE01", "RFPJ01", "RFPK01", "RFPP01",
"RFPW01", "RGWE41", "RGWJ41", "RGWP41", "RGWX41", "RMCE01", "RMCJ01", "RMCK01", "RMCP01",
};
DEBUG_ASSERT(std::is_sorted(channel_discs.cbegin(), channel_discs.cend()));
DEBUG_ASSERT(std::ranges::is_sorted(channel_discs));
return std::binary_search(channel_discs.cbegin(), channel_discs.cend(),
std::string_view(m_volume.GetGameID()));
return std::ranges::binary_search(channel_discs, std::string_view(m_volume.GetGameID()));
}
bool VolumeVerifier::ShouldHaveInstallPartition() const
@ -731,16 +724,15 @@ bool VolumeVerifier::ShouldHaveInstallPartition() const
static constexpr std::array<std::string_view, 4> dragon_quest_x = {"S4MJGD", "S4SJGD", "S6TJGD",
"SDQJGD"};
const std::string& game_id = m_volume.GetGameID();
return std::any_of(dragon_quest_x.cbegin(), dragon_quest_x.cend(),
[&game_id](std::string_view x) { return x == game_id; });
return std::ranges::any_of(dragon_quest_x,
[&game_id](std::string_view x) { return x == game_id; });
}
bool VolumeVerifier::ShouldHaveMasterpiecePartitions() const
{
static constexpr std::array<std::string_view, 4> ssbb = {"RSBE01", "RSBJ01", "RSBK01", "RSBP01"};
const std::string& game_id = m_volume.GetGameID();
return std::any_of(ssbb.cbegin(), ssbb.cend(),
[&game_id](std::string_view x) { return x == game_id; });
return std::ranges::any_of(ssbb, [&game_id](std::string_view x) { return x == game_id; });
}
bool VolumeVerifier::ShouldBeDualLayer() const
@ -753,10 +745,9 @@ bool VolumeVerifier::ShouldBeDualLayer() const
"SLSEXJ", "SLSP01", "SQIE4Q", "SQIP4Q", "SQIY4Q", "SR5E41", "SR5P41", "SUOE41", "SUOP41",
"SVXX52", "SVXY52", "SX4E01", "SX4P01", "SZ3EGT", "SZ3PGT",
};
DEBUG_ASSERT(std::is_sorted(dual_layer_discs.cbegin(), dual_layer_discs.cend()));
DEBUG_ASSERT(std::ranges::is_sorted(dual_layer_discs));
return std::binary_search(dual_layer_discs.cbegin(), dual_layer_discs.cend(),
std::string_view(m_volume.GetGameID()));
return std::ranges::binary_search(dual_layer_discs, std::string_view(m_volume.GetGameID()));
}
void VolumeVerifier::CheckVolumeSize()
@ -1042,7 +1033,7 @@ void VolumeVerifier::CheckSuperPaperMario()
if (!m_volume.Read(offset, length, data.data(), partition))
return;
if (std::any_of(data.cbegin(), data.cend(), [](u8 x) { return x != 0; }))
if (std::ranges::any_of(data, [](u8 x) { return x != 0; }))
{
AddProblem(Severity::High,
Common::GetStringT("Some padding data that should be zero is not zero. "
@ -1062,8 +1053,8 @@ void VolumeVerifier::SetUpHashing()
m_scrubber.SetupScrub(m_volume);
}
std::sort(m_groups.begin(), m_groups.end(),
[](const GroupToVerify& a, const GroupToVerify& b) { return a.offset < b.offset; });
std::ranges::sort(
m_groups, [](const GroupToVerify& a, const GroupToVerify& b) { return a.offset < b.offset; });
if (m_hashes_to_calculate.crc32)
m_crc32_context = Common::StartCRC32();
@ -1346,8 +1337,9 @@ void VolumeVerifier::Finish()
}
// Show the most serious problems at the top
std::stable_sort(m_result.problems.begin(), m_result.problems.end(),
[](const Problem& p1, const Problem& p2) { return p1.severity > p2.severity; });
std::ranges::stable_sort(m_result.problems, [](const Problem& p1, const Problem& p2) {
return p1.severity > p2.severity;
});
const Severity highest_severity =
m_result.problems.empty() ? Severity::None : m_result.problems[0].severity;

View File

@ -176,7 +176,7 @@ IOS::ES::TicketReader VolumeWAD::GetTicketWithFixedCommonKey() const
return m_ticket;
const std::vector<u8> sig = m_ticket.GetSignatureData();
if (!std::all_of(sig.cbegin(), sig.cend(), [](u8 a) { return a == 0; }))
if (!std::ranges::all_of(sig, [](u8 a) { return a == 0; }))
{
// This does not look like a typical "invalid common key index" ticket, so let's assume
// the index is correct. This saves some time when reading properly signed titles.

View File

@ -1119,7 +1119,7 @@ bool WIARVZFileReader<RVZ>::TryReuse(std::map<ReuseID, GroupEntry>* reusable_gro
static bool AllAre(const std::vector<u8>& data, u8 x)
{
return std::all_of(data.begin(), data.end(), [x](u8 y) { return x == y; });
return std::ranges::all_of(data, [x](u8 y) { return x == y; });
}
static bool AllAre(const u8* begin, const u8* end, u8 x)

View File

@ -141,9 +141,8 @@ void ARCodeWidget::SortAlphabetically()
void ARCodeWidget::SortEnabledCodesFirst()
{
std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) {
return a.enabled && a.enabled != b.enabled;
});
std::ranges::stable_sort(
m_ar_codes, [](const auto& a, const auto& b) { return a.enabled && a.enabled != b.enabled; });
UpdateList();
SaveCodes();
@ -151,7 +150,7 @@ void ARCodeWidget::SortEnabledCodesFirst()
void ARCodeWidget::SortDisabledCodesFirst()
{
std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) {
std::ranges::stable_sort(m_ar_codes, [](const auto& a, const auto& b) {
return !a.enabled && a.enabled != b.enabled;
});

View File

@ -287,7 +287,7 @@ void GeckoCodeWidget::SortAlphabetically()
void GeckoCodeWidget::SortEnabledCodesFirst()
{
std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) {
std::ranges::stable_sort(m_gecko_codes, [](const auto& a, const auto& b) {
return a.enabled && a.enabled != b.enabled;
});
@ -297,7 +297,7 @@ void GeckoCodeWidget::SortEnabledCodesFirst()
void GeckoCodeWidget::SortDisabledCodesFirst()
{
std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) {
std::ranges::stable_sort(m_gecko_codes, [](const auto& a, const auto& b) {
return !a.enabled && a.enabled != b.enabled;
});
@ -369,7 +369,7 @@ void GeckoCodeWidget::DownloadCodes()
for (const auto& code : codes)
{
auto it = std::find(m_gecko_codes.begin(), m_gecko_codes.end(), code);
auto it = std::ranges::find(m_gecko_codes, code);
if (it == m_gecko_codes.end())
{

View File

@ -138,10 +138,9 @@ void GraphicsModListWidget::RefreshModList()
for (const GraphicsModConfig& mod : m_mod_group.GetMods())
{
// If no group matches the mod's features, or if the mod has no features, skip it
if (std::none_of(mod.m_features.begin(), mod.m_features.end(),
[&groups](const GraphicsModFeatureConfig& feature) {
return groups.contains(feature.m_group);
}))
if (std::ranges::none_of(mod.m_features, [&groups](const GraphicsModFeatureConfig& feature) {
return groups.contains(feature.m_group);
}))
{
continue;
}

View File

@ -610,9 +610,9 @@ void ShakeMappingIndicator::Draw()
}
// Grid line.
if (m_grid_line_position ||
std::any_of(m_position_samples.begin(), m_position_samples.end(),
[](const Common::Vec3& v) { return v.LengthSquared() != 0.0; }))
if (m_grid_line_position || std::ranges::any_of(m_position_samples, [](const Common::Vec3& v) {
return v.LengthSquared() != 0.0;
}))
{
// Only start moving the line if there's non-zero data.
m_grid_line_position = (m_grid_line_position + 1) % HISTORY_COUNT;
@ -913,7 +913,7 @@ CalibrationWidget::CalibrationWidget(ControllerEmu::ReshapableInput& input,
m_informative_timer = new QTimer(this);
connect(m_informative_timer, &QTimer::timeout, this, [this] {
// If the user has started moving we'll assume they know what they are doing.
if (*std::max_element(m_calibration_data.begin(), m_calibration_data.end()) > 0.5)
if (*std::ranges::max_element(m_calibration_data) > 0.5)
return;
ModalMessageBox::information(

View File

@ -155,8 +155,8 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
[group_enable_checkbox, group] { group_enable_checkbox->setChecked(group->enabled); });
}
const auto advanced_setting_count = std::count_if(
group->numeric_settings.begin(), group->numeric_settings.end(), [](auto& setting) {
const auto advanced_setting_count =
std::ranges::count_if(group->numeric_settings, [](auto& setting) {
return setting->GetVisibility() == ControllerEmu::SettingVisibility::Advanced;
});

View File

@ -181,8 +181,8 @@ QGroupBox* NewPatchDialog::CreateEntry(const PatchEngine::PatchEntry& entry)
m_entry_layout->removeWidget(box);
box->deleteLater();
m_entries.erase(std::find_if(m_entries.begin(), m_entries.end(),
[new_entry](const auto& e) { return e.get() == new_entry; }));
m_entries.erase(std::ranges::find_if(
m_entries, [new_entry](const auto& e) { return e.get() == new_entry; }));
}
});

View File

@ -52,8 +52,8 @@ ConvertDialog::ConvertDialog(QList<std::shared_ptr<const UICommon::GameFile>> fi
m_format->addItem(QStringLiteral("GCZ"), static_cast<int>(DiscIO::BlobType::GCZ));
m_format->addItem(QStringLiteral("WIA"), static_cast<int>(DiscIO::BlobType::WIA));
m_format->addItem(QStringLiteral("RVZ"), static_cast<int>(DiscIO::BlobType::RVZ));
if (std::all_of(m_files.begin(), m_files.end(),
[](const auto& file) { return file->GetBlobType() == DiscIO::BlobType::PLAIN; }))
if (std::ranges::all_of(
m_files, [](const auto& file) { return file->GetBlobType() == DiscIO::BlobType::PLAIN; }))
{
m_format->setCurrentIndex(m_format->count() - 1);
}
@ -153,7 +153,7 @@ void ConvertDialog::OnFormatChanged()
// To support legacy versions of dolphin, we have to check the GCZ block size
// See DiscIO::IsGCZBlockSizeLegacyCompatible() for details
const auto block_size_ok = [this](int block_size) {
return std::all_of(m_files.begin(), m_files.end(), [block_size](const auto& file) {
return std::ranges::all_of(m_files, [block_size](const auto& file) {
return DiscIO::IsGCZBlockSizeLegacyCompatible(block_size, file->GetVolumeSize());
});
};
@ -250,7 +250,7 @@ void ConvertDialog::OnFormatChanged()
// Block scrubbing of RVZ containers and Datel discs
const bool scrubbing_allowed =
format != DiscIO::BlobType::RVZ &&
std::none_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsDatelDisc));
std::ranges::none_of(m_files, std::mem_fn(&UICommon::GameFile::IsDatelDisc));
m_scrub->setEnabled(scrubbing_allowed);
if (!scrubbing_allowed)
@ -309,7 +309,7 @@ void ConvertDialog::Convert()
}
if (!scrub && format == DiscIO::BlobType::GCZ &&
std::any_of(m_files.begin(), m_files.end(), [](const auto& file) {
std::ranges::any_of(m_files, [](const auto& file) {
return file->GetPlatform() == DiscIO::Platform::WiiDisc && !file->IsDatelDisc();
}))
{
@ -321,7 +321,7 @@ void ConvertDialog::Convert()
}
}
if (std::any_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsNKit)))
if (std::ranges::any_of(m_files, std::mem_fn(&UICommon::GameFile::IsNKit)))
{
if (!ShowAreYouSureDialog(
tr("Dolphin can't convert NKit files to non-NKit files. Converting an NKit file in "

View File

@ -846,7 +846,7 @@ void AssemblerWidget::CloseTab(int index, AsmEditor* editor)
int AssemblerWidget::AllocateTabNum()
{
auto min_it = std::min_element(m_free_editor_nums.begin(), m_free_editor_nums.end());
auto min_it = std::ranges::min_element(m_free_editor_nums);
if (min_it == m_free_editor_nums.end())
{
return m_unnamed_editor_count++;

View File

@ -1067,12 +1067,10 @@ QMenu* BranchWatchDialog::GetTableContextMenu(const QModelIndex& index)
m_act_insert_nop->setVisible(false);
m_act_insert_blr->setVisible(true);
const bool all_branches_save_lr =
core_initialized &&
std::all_of(
m_index_list_temp.begin(), m_index_list_temp.end(), [this](const QModelIndex& idx) {
const QModelIndex sibling = idx.siblingAtColumn(Column::Instruction);
return BranchSavesLR(m_table_proxy->data(sibling, UserRole::ClickRole).value<u32>());
});
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& idx) {
const QModelIndex sibling = idx.siblingAtColumn(Column::Instruction);
return BranchSavesLR(m_table_proxy->data(sibling, UserRole::ClickRole).value<u32>());
});
m_act_insert_blr->setEnabled(all_branches_save_lr);
m_act_copy_address->setEnabled(true);
m_mnu_set_breakpoint->setEnabled(true);
@ -1084,11 +1082,9 @@ QMenu* BranchWatchDialog::GetTableContextMenu(const QModelIndex& index)
m_act_insert_nop->setVisible(false);
m_act_insert_blr->setVisible(true);
const bool all_symbols_valid =
core_initialized &&
std::all_of(m_index_list_temp.begin(), m_index_list_temp.end(),
[this](const QModelIndex& idx) {
return m_table_proxy->data(idx, UserRole::ClickRole).isValid();
});
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& idx) {
return m_table_proxy->data(idx, UserRole::ClickRole).isValid();
});
m_act_insert_blr->setEnabled(all_symbols_valid);
m_act_copy_address->setEnabled(all_symbols_valid);
m_mnu_set_breakpoint->setEnabled(all_symbols_valid);

Some files were not shown because too many files have changed in this diff Show More