From 860e6cf5cb7d96499aecf6f6067783bdb71c29ad Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:43:52 -0700 Subject: 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. --- Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.cpp') 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& 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(); -- cgit v1.2.3 From 2b0cd16c8c266bc1e298e49d4009eab8c9c23f99 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:05:17 -0700 Subject: Modernize `std::none_of` with ranges In JitRegCache.cpp, the lambda predicate were replaced by a pointer to member function because ranges algorithms are able to 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. In BoundingBox.cpp, the lambda predicate was returning the bool element unchanged, so `std::identity` was a better fit. --- Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.cpp') diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index dd897c2535..7fdf677a91 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -305,9 +305,10 @@ bool HotkeySuppressions::IsSuppressedIgnoringModifiers(Device::Input* input, return i1 && i2 && (i1 == i2 || i1->IsChild(i2) || i2->IsChild(i1)); }; - return std::any_of(it, it_end, [&](auto& s) { - return std::none_of(begin(ignore_modifiers), end(ignore_modifiers), - [&](auto& m) { return is_same_modifier(m->GetInput(), s.first.second); }); + return std::any_of(it, it_end, [&](const auto& s) { + return std::ranges::none_of(ignore_modifiers, [&](const auto& m) { + return is_same_modifier(m->GetInput(), s.first.second); + }); }); } -- cgit v1.2.3