mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Added non-trivial move operations.
Removed the default move constructor and operator.
This commit is contained in:
parent
c0acaef204
commit
487c97afaf
@ -113,16 +113,16 @@ public:
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Defaulted move constructor
|
||||
/// \brief Move constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Shader(Shader&&) noexcept = default;
|
||||
Shader(Shader&& source) noexcept;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Defaulted move assignment
|
||||
/// \brief Move assignment
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Shader& operator=(Shader&&) noexcept = default;
|
||||
Shader& operator=(Shader&& right) noexcept;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -40,9 +40,9 @@
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifndef SFML_OPENGL_ES
|
||||
|
||||
#if defined(SFML_SYSTEM_MACOS) || defined(SFML_SYSTEM_IOS)
|
||||
@ -250,6 +250,38 @@ Shader::~Shader()
|
||||
glCheck(GLEXT_glDeleteObject(castToGlHandle(m_shaderProgram)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Shader::Shader(Shader&& source) noexcept :
|
||||
m_shaderProgram(std::exchange(source.m_shaderProgram, 0U)),
|
||||
m_currentTexture(std::exchange(source.m_currentTexture, -1)),
|
||||
m_textures(std::move(source.m_textures)),
|
||||
m_uniforms(std::move(source.m_uniforms))
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Shader& Shader::operator=(Shader&& right) noexcept
|
||||
{
|
||||
// Make sure we aren't moving ourselves.
|
||||
if (&right == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
// Explicit scope for RAII
|
||||
{
|
||||
// Destroy effect program
|
||||
TransientContextLock lock;
|
||||
if (m_shaderProgram)
|
||||
glCheck(GLEXT_glDeleteObject(castToGlHandle(m_shaderProgram)));
|
||||
}
|
||||
|
||||
// Move the contents of right.
|
||||
m_shaderProgram = std::exchange(right.m_shaderProgram, 0U);
|
||||
m_currentTexture = std::exchange(right.m_currentTexture, -1);
|
||||
m_textures = std::move(right.m_textures);
|
||||
m_uniforms = std::move(right.m_uniforms);
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Shader::loadFromFile(const std::filesystem::path& filename, Type type)
|
||||
|
Loading…
Reference in New Issue
Block a user