From a1b26db389d45f3cdfd434fb5f438300fc414aae Mon Sep 17 00:00:00 2001 From: Lioncash <mathew1800@gmail.com> Date: Wed, 29 May 2019 02:47:01 -0400 Subject: [PATCH 1/2] common/math_util: Provide a template deduction guide for Common::Rectangle Allows for things such as: auto rect = Common::Rectangle{0, 0, 0, 0}; as opposed to being required to explicitly write out the underlying type, such as: auto rect = Common::Rectangle<int>{0, 0, 0, 0}; The only requirement for the deduction is that all constructor arguments be the same type. --- src/common/math_util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/math_util.h b/src/common/math_util.h index cff3d48c5..d6c35ee89 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -41,4 +41,7 @@ struct Rectangle { } }; +template <typename T> +Rectangle(T, T, T, T)->Rectangle<T>; + } // namespace Common From 79439fc55625ea9db4887c384f57437e53cf345e Mon Sep 17 00:00:00 2001 From: Lioncash <mathew1800@gmail.com> Date: Wed, 29 May 2019 01:33:00 -0400 Subject: [PATCH 2/2] input_common/sdl/sdl_impl: Silence sign conversion warnings Makes the conversions explicit, as opposed to implicit. --- src/input_common/sdl/sdl_impl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 5949ecbae..0b69bfede 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -143,9 +143,9 @@ std::shared_ptr<SDLJoystick> SDLState::GetSDLJoystickByGUID(const std::string& g std::lock_guard lock{joystick_map_mutex}; const auto it = joystick_map.find(guid); if (it != joystick_map.end()) { - while (it->second.size() <= port) { - auto joystick = std::make_shared<SDLJoystick>(guid, it->second.size(), nullptr, - [](SDL_Joystick*) {}); + while (it->second.size() <= static_cast<std::size_t>(port)) { + auto joystick = std::make_shared<SDLJoystick>(guid, static_cast<int>(it->second.size()), + nullptr, [](SDL_Joystick*) {}); it->second.emplace_back(std::move(joystick)); } return it->second[port];