diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index 66035b45..8f12edc6 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -72,10 +72,19 @@ public: //////////////////////////////////////////////////////////// /// \brief Copy constructor /// - /// \param copy instance to copy + /// \param copied instance to copy /// //////////////////////////////////////////////////////////// - Texture(const Texture& copy); + Texture(const Texture& copied); + + //////////////////////////////////////////////////////////// + /// \brief Move constructor + /// + /// \param moved instance to move from. Behaves like a + /// default-constructed object after the move. + /// + //////////////////////////////////////////////////////////// + Texture(Texture&& moved) noexcept; //////////////////////////////////////////////////////////// /// \brief Destructor @@ -507,16 +516,16 @@ public: /// //////////////////////////////////////////////////////////// bool generateMipmap(); - + //////////////////////////////////////////////////////////// - /// \brief Overload of assignment operator + /// \brief Combined copy/move assignment operator /// - /// \param right Instance to assign + /// \param right Instance to assign (copied or moved) /// /// \return Reference to self /// //////////////////////////////////////////////////////////// - Texture& operator =(const Texture& right); + Texture& operator =(Texture right); //////////////////////////////////////////////////////////// /// \brief Swap the contents of this texture with those of another diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index a139115d..ce52ec80 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -101,6 +101,14 @@ m_cacheId (getUniqueId()) } +//////////////////////////////////////////////////////////// +Texture::Texture(Texture&& moved) noexcept : +Texture() +{ + swap(moved); +} + + //////////////////////////////////////////////////////////// Texture::~Texture() { @@ -809,11 +817,9 @@ unsigned int Texture::getMaximumSize() //////////////////////////////////////////////////////////// -Texture& Texture::operator =(const Texture& right) +Texture& Texture::operator =(Texture right) { - Texture temp(right); - - swap(temp); + swap(right); return *this; }