Merge pull request #13090 from mitaclaw/ranges-modernization-1-trivial

Ranges Algorithms Modernization - Trivial
This commit is contained in:
JosJuice
2024-10-15 17:08:55 +02:00
committed by GitHub
52 changed files with 106 additions and 118 deletions

View File

@ -53,8 +53,7 @@ struct TwoPointCalibration
}
else
{
return std::equal(std::begin(max.data), std::end(max.data), std::begin(zero.data),
std::not_equal_to<>());
return std::ranges::equal(max.data, zero.data, std::ranges::not_equal_to{});
}
}

View File

@ -176,15 +176,14 @@ Joystick::Joystick(const LPDIRECTINPUTDEVICE8 device) : m_device(device)
std::list<DIDEVICEOBJECTINSTANCE> 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);
}
// 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()

View File

@ -101,7 +101,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
}
else
{
std::sort(alternation.begin(), alternation.end());
std::ranges::sort(alternation);
alternations.push_back(fmt::to_string(fmt::join(alternation, "&")));
}
};
@ -128,7 +128,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
handle_release();
// Remove duplicates
std::sort(alternations.begin(), alternations.end());
std::ranges::sort(alternations);
alternations.erase(std::unique(alternations.begin(), alternations.end()), alternations.end());
return fmt::to_string(fmt::join(alternations, "|"));

View File

@ -111,8 +111,7 @@ ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting,
}
std::vector<std::string> result;
std::set_intersection(profiles.begin(), profiles.end(), profiles_from_setting.begin(),
profiles_from_setting.end(), std::back_inserter(result));
std::ranges::set_intersection(profiles, profiles_from_setting, std::back_inserter(result));
return result;
}