mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Modernize std::all_of
with ranges
In DITSpecification.cpp, MaterialAsset.cpp, and ShaderAsset.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those. In NetPlayClient.cpp, the non-trivial `NetPlay::Player` elements were being passed by value in `NetPlayClient::DoAllPlayersHaveGame()`. This has been fixed. In WIABlob.cpp, the second example's predicate was returning the `std::optional` by value instead of implicitly converting it to a bool. This has been fixed.
This commit is contained in:
@ -495,10 +495,8 @@ public:
|
||||
ControlState GetValue() const override
|
||||
{
|
||||
// True if we have no modifiers
|
||||
const bool modifiers_pressed = std::all_of(m_modifiers.begin(), m_modifiers.end(),
|
||||
[](const std::unique_ptr<ControlExpression>& input) {
|
||||
return input->GetValue() > CONDITION_THRESHOLD;
|
||||
});
|
||||
const bool modifiers_pressed = std::ranges::all_of(
|
||||
m_modifiers, [](const auto& input) { return input->GetValue() > CONDITION_THRESHOLD; });
|
||||
|
||||
const auto final_input_state = m_final_input->GetValueIgnoringSuppression();
|
||||
|
||||
|
@ -25,8 +25,8 @@ IMUAccelerometer::IMUAccelerometer(std::string name_, std::string ui_name_)
|
||||
|
||||
bool IMUAccelerometer::AreInputsBound() const
|
||||
{
|
||||
return std::all_of(controls.begin(), controls.end(),
|
||||
[](const auto& control) { return control->control_ref->BoundCount() > 0; });
|
||||
return std::ranges::all_of(
|
||||
controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; });
|
||||
}
|
||||
|
||||
std::optional<IMUAccelerometer::StateData> IMUAccelerometer::GetState() const
|
||||
|
@ -123,8 +123,8 @@ auto IMUGyroscope::GetRawState() const -> StateData
|
||||
|
||||
bool IMUGyroscope::AreInputsBound() const
|
||||
{
|
||||
return std::all_of(controls.begin(), controls.end(),
|
||||
[](const auto& control) { return control->control_ref->BoundCount() > 0; });
|
||||
return std::ranges::all_of(
|
||||
controls, [](const auto& control) { return control->control_ref->BoundCount() > 0; });
|
||||
}
|
||||
|
||||
bool IMUGyroscope::CanCalibrate() const
|
||||
|
@ -44,7 +44,7 @@ std::string GetExpressionForControl(const std::string& control_name,
|
||||
{
|
||||
// If our expression contains any non-alpha characters
|
||||
// we should quote it
|
||||
if (!std::all_of(expr.begin(), expr.end(), Common::IsAlpha))
|
||||
if (!std::ranges::all_of(expr, Common::IsAlpha))
|
||||
expr = fmt::format("`{}`", expr);
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,7 @@ bool ProcessSpecificationV1(picojson::value& root, std::vector<Data>& input_text
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!std::all_of(region_offsets.begin(), region_offsets.end(),
|
||||
[](picojson::value val) { return val.is<double>(); }))
|
||||
if (!std::ranges::all_of(region_offsets, &picojson::value::is<double>))
|
||||
{
|
||||
ERROR_LOG_FMT(
|
||||
VIDEO,
|
||||
|
Reference in New Issue
Block a user