From 4cc5e1972ae5643af001276758c4456ee7292f41 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:24:22 -0700 Subject: Modernize `std::count_if` with ranges --- .../Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp index 577bd761d4..5d3e353a0a 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp @@ -176,9 +176,8 @@ Joystick::Joystick(const LPDIRECTINPUTDEVICE8 device) : m_device(device) std::list objects; if (SUCCEEDED(m_device->EnumObjects(DIEnumDeviceObjectsCallback, (LPVOID)&objects, DIDFT_AXIS))) { - const int num_ff_axes = - std::count_if(std::begin(objects), std::end(objects), - [](const auto& pdidoi) { return (pdidoi.dwFlags & DIDOI_FFACTUATOR) != 0; }); + const int num_ff_axes = std::ranges::count_if( + objects, [](const auto& pdidoi) { return (pdidoi.dwFlags & DIDOI_FFACTUATOR) != 0; }); InitForceFeedback(m_device, num_ff_axes); } -- cgit v1.2.3 From 9bd1dae41d8703e70196397722f98364bae63035 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:16:36 -0700 Subject: Modernize `std::fill` with ranges In DSPCore.cpp, there were two `std::fill` uses that could be simplified using `std::fill_n`. Due to their proximity with other `std::fill` algorithms being modernized with ranges, I chose to make these examples into the rare `std::ranges::fill_n`. --- Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp index 5d3e353a0a..a78c310f24 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp @@ -183,7 +183,7 @@ Joystick::Joystick(const LPDIRECTINPUTDEVICE8 device) : m_device(device) // Set hats to center: // "The center position is normally reported as -1" -MSDN - std::fill(std::begin(m_state_in.rgdwPOV), std::end(m_state_in.rgdwPOV), -1); + std::ranges::fill(m_state_in.rgdwPOV, -1); } Joystick::~Joystick() -- cgit v1.2.3