summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-29 11:43:52 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-12-15 19:50:34 -0800
commit860e6cf5cb7d96499aecf6f6067783bdb71c29ad (patch)
tree212a451cbdd72d6525703c2f1369198fbdbe2b85 /Source/Core/InputCommon
parent826e2bbf98ca5c6088c3d19968272b29fc335972 (diff)
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.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControlReference/ExpressionParser.cpp6
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp2
-rw-r--r--Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp3
5 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
index b558d6b78f..dd897c2535 100644
--- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
+++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
@@ -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();
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
index dfd282d533..d6cb4b95ff 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUAccelerometer.cpp
@@ -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
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp
index 2e8c4bb18c..0ad720dcdb 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp
@@ -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
diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
index 1877e8294c..fb9d43f22f 100644
--- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
@@ -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);
}
diff --git a/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp b/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp
index f5409b518f..70c4651a24 100644
--- a/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp
+++ b/Source/Core/InputCommon/DynamicInputTextures/DITSpecification.cpp
@@ -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,