From 14cff7406f03faf0453ef7986f8328727ca8bb3a Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 23 Jun 2024 15:38:16 -0600 Subject: [PATCH] Disallow construction from `const T&&` --- include/SFML/Audio/Sound.hpp | 4 ++-- include/SFML/Graphics/Shader.hpp | 2 +- include/SFML/Graphics/Sprite.hpp | 6 +++--- include/SFML/Graphics/Text.hpp | 4 ++-- test/Audio/Sound.test.cpp | 1 + test/Graphics/Sprite.test.cpp | 3 +++ test/Graphics/Text.test.cpp | 1 + 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index a3b4c199e..5e763a2de 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -59,7 +59,7 @@ public: /// \brief Disallow construction from a temporary sound buffer /// //////////////////////////////////////////////////////////// - explicit Sound(SoundBuffer&& buffer) = delete; + explicit Sound(const SoundBuffer&& buffer) = delete; //////////////////////////////////////////////////////////// /// \brief Copy constructor @@ -130,7 +130,7 @@ public: /// \brief Disallow setting from a temporary sound buffer /// //////////////////////////////////////////////////////////// - void setBuffer(SoundBuffer&& buffer) = delete; + void setBuffer(const SoundBuffer&& buffer) = delete; //////////////////////////////////////////////////////////// /// \brief Set whether or not the sound should loop after reaching the end diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index 3aef99703..48b725c04 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -493,7 +493,7 @@ public: /// \brief Disallow setting from a temporary texture /// //////////////////////////////////////////////////////////// - void setUniform(const std::string& name, Texture&& texture) = delete; + void setUniform(const std::string& name, const Texture&& texture) = delete; //////////////////////////////////////////////////////////// /// \brief Specify current texture as \p sampler2D uniform diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp index 69648de68..9267a9503 100644 --- a/include/SFML/Graphics/Sprite.hpp +++ b/include/SFML/Graphics/Sprite.hpp @@ -64,7 +64,7 @@ public: /// \brief Disallow construction from a temporary texture /// //////////////////////////////////////////////////////////// - explicit Sprite(Texture&& texture) = delete; + explicit Sprite(const Texture&& texture) = delete; //////////////////////////////////////////////////////////// /// \brief Construct the sprite from a sub-rectangle of a source texture @@ -81,7 +81,7 @@ public: /// \brief Disallow construction from a temporary texture /// //////////////////////////////////////////////////////////// - Sprite(Texture&& texture, const IntRect& rectangle) = delete; + Sprite(const Texture&& texture, const IntRect& rectangle) = delete; //////////////////////////////////////////////////////////// /// \brief Change the source texture of the sprite @@ -108,7 +108,7 @@ public: /// \brief Disallow setting from a temporary texture /// //////////////////////////////////////////////////////////// - void setTexture(Texture&& texture, bool resetRect = false) = delete; + void setTexture(const Texture&& texture, bool resetRect = false) = delete; //////////////////////////////////////////////////////////// /// \brief Set the sub-rectangle of the texture that the sprite will display diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index a2c2cad3a..a20b4cf63 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -90,7 +90,7 @@ public: /// \brief Disallow construction from a temporary font /// //////////////////////////////////////////////////////////// - Text(Font&& font, String string = "", unsigned int characterSize = 30) = delete; + Text(const Font&& font, String string = "", unsigned int characterSize = 30) = delete; //////////////////////////////////////////////////////////// /// \brief Set the text's string @@ -134,7 +134,7 @@ public: /// \brief Disallow setting from a temporary font /// //////////////////////////////////////////////////////////// - void setFont(Font&& font) = delete; + void setFont(const Font&& font) = delete; //////////////////////////////////////////////////////////// /// \brief Set the character size diff --git a/test/Audio/Sound.test.cpp b/test/Audio/Sound.test.cpp index 0cfc10296..141676f71 100644 --- a/test/Audio/Sound.test.cpp +++ b/test/Audio/Sound.test.cpp @@ -16,6 +16,7 @@ TEST_CASE("[Audio] sf::Sound", runAudioDeviceTests()) SECTION("Type traits") { STATIC_CHECK(!std::is_constructible_v); + STATIC_CHECK(!std::is_constructible_v); STATIC_CHECK(std::is_copy_constructible_v); STATIC_CHECK(std::is_copy_assignable_v); STATIC_CHECK(std::is_move_constructible_v); diff --git a/test/Graphics/Sprite.test.cpp b/test/Graphics/Sprite.test.cpp index 709fdd9d1..9d71b6ecd 100644 --- a/test/Graphics/Sprite.test.cpp +++ b/test/Graphics/Sprite.test.cpp @@ -13,6 +13,9 @@ TEST_CASE("[Graphics] sf::Sprite", runDisplayTests()) SECTION("Type traits") { STATIC_CHECK(!std::is_constructible_v); + STATIC_CHECK(!std::is_constructible_v); + STATIC_CHECK(!std::is_constructible_v); + STATIC_CHECK(!std::is_constructible_v); STATIC_CHECK(std::is_copy_constructible_v); STATIC_CHECK(std::is_copy_assignable_v); STATIC_CHECK(std::is_nothrow_move_constructible_v); diff --git a/test/Graphics/Text.test.cpp b/test/Graphics/Text.test.cpp index c4be7b595..72b3c5b71 100644 --- a/test/Graphics/Text.test.cpp +++ b/test/Graphics/Text.test.cpp @@ -14,6 +14,7 @@ TEST_CASE("[Graphics] sf::Text", runDisplayTests()) SECTION("Type traits") { STATIC_CHECK(!std::is_constructible_v); + STATIC_CHECK(!std::is_constructible_v); STATIC_CHECK(std::is_copy_constructible_v); STATIC_CHECK(std::is_copy_assignable_v); STATIC_CHECK(std::is_nothrow_move_constructible_v);