diff --git a/examples/joystick/Joystick.cpp b/examples/joystick/Joystick.cpp index bca3396d8..05d997681 100644 --- a/examples/joystick/Joystick.cpp +++ b/examples/joystick/Joystick.cpp @@ -18,17 +18,17 @@ struct JoystickObject sf::Text value; }; -using Texts = std::unordered_map; +using Texts = std::unordered_map; Texts texts; std::ostringstream sstr; float threshold = 0.1f; // Axes labels in as strings -const std::array axislabels = {"X", "Y", "Z", "R", "U", "V", "PovX", "PovY"}; +const std::array axislabels = {"X", "Y", "Z", "R", "U", "V", "PovX", "PovY"}; // Helper to set text entries to a specified value template -void set(const std::string& label, const T& value) +void set(std::string_view label, const T& value) { sstr.str(""); sstr << value; @@ -122,7 +122,8 @@ int main() for (unsigned int i = 0; i < sf::Joystick::AxisCount; ++i) { const auto [it, success] = texts.try_emplace(axislabels[i], - JoystickObject{{font, axislabels[i] + ":"}, {font, "N/A"}}); + JoystickObject{{font, std::string(axislabels[i]) + ":"}, + {font, "N/A"}}); auto& [label, value] = it->second; label.setPosition({5.f, 5.f + (static_cast(i + 4) * font.getLineSpacing(14))}); value.setPosition({80.f, 5.f + (static_cast(i + 4) * font.getLineSpacing(14))});