Modernize std::any_of with ranges

In WiimoteReal.cpp, JitRegCache.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those.

In ConvertDialog.cpp, the `std::mem_fn` helper was removed because ranges algorithms are able to handle pointers to member functions as predicates.
This commit is contained in:
mitaclaw
2024-09-30 17:26:50 -07:00
parent 860e6cf5cb
commit 140252ffc0
34 changed files with 69 additions and 82 deletions

View File

@ -598,9 +598,8 @@ void ShakeMappingIndicator::Update(float elapsed_seconds)
m_position_samples.push_front(ShakeSample{m_motion_state.position / MAX_DISTANCE});
const bool any_non_zero_samples =
std::any_of(m_position_samples.begin(), m_position_samples.end(),
[](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
const bool any_non_zero_samples = std::ranges::any_of(
m_position_samples, [](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
// Only start moving the line if there's non-zero data.
if (m_grid_line_position || any_non_zero_samples)

View File

@ -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, &UICommon::GameFile::IsNKit))
{
if (!ShowAreYouSureDialog(
tr("Dolphin can't convert NKit files to non-NKit files. Converting an NKit file in "

View File

@ -428,8 +428,7 @@ void AudioPane::OnVolumeChanged(int volume)
void AudioPane::CheckNeedForLatencyControl()
{
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
m_latency_control_supported =
std::any_of(backends.cbegin(), backends.cend(), AudioCommon::SupportsLatencyControl);
m_latency_control_supported = std::ranges::any_of(backends, AudioCommon::SupportsLatencyControl);
}
QString AudioPane::GetDPL2QualityLabel(AudioCommon::DPL2Quality value) const