mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-24 09:20:58 +01:00
gl_resource_manager: Add missing noexcept specifiers to move constructors and assignment operators
Standard library containers may use std::move_if_noexcept to perform move operations. If a move cannot be performed under these circumstances, then a copy is attempted. Given we only intend for these types to be move-only this can be somewhat problematic. By defining these to be noexcept we prevent cases where copies may be attempted.
This commit is contained in:
parent
1df3a7710e
commit
ab71997b2c
1 changed files with 19 additions and 20 deletions
|
@ -14,13 +14,13 @@ class OGLTexture : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLTexture() = default;
|
OGLTexture() = default;
|
||||||
|
|
||||||
OGLTexture(OGLTexture&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLTexture(OGLTexture&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLTexture() {
|
~OGLTexture() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLTexture& operator=(OGLTexture&& o) {
|
OGLTexture& operator=(OGLTexture&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -49,13 +49,13 @@ class OGLSampler : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLSampler() = default;
|
OGLSampler() = default;
|
||||||
|
|
||||||
OGLSampler(OGLSampler&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLSampler(OGLSampler&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLSampler() {
|
~OGLSampler() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLSampler& operator=(OGLSampler&& o) {
|
OGLSampler& operator=(OGLSampler&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -84,13 +84,13 @@ class OGLShader : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLShader() = default;
|
OGLShader() = default;
|
||||||
|
|
||||||
OGLShader(OGLShader&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLShader(OGLShader&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLShader() {
|
~OGLShader() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLShader& operator=(OGLShader&& o) {
|
OGLShader& operator=(OGLShader&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -118,13 +118,13 @@ class OGLProgram : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLProgram() = default;
|
OGLProgram() = default;
|
||||||
|
|
||||||
OGLProgram(OGLProgram&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLProgram(OGLProgram&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLProgram() {
|
~OGLProgram() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLProgram& operator=(OGLProgram&& o) {
|
OGLProgram& operator=(OGLProgram&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -165,13 +165,12 @@ public:
|
||||||
class OGLPipeline : private NonCopyable {
|
class OGLPipeline : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLPipeline() = default;
|
OGLPipeline() = default;
|
||||||
OGLPipeline(OGLPipeline&& o) {
|
OGLPipeline(OGLPipeline&& o) noexcept : handle{std::exchange<GLuint>(o.handle, 0)} {}
|
||||||
handle = std::exchange<GLuint>(o.handle, 0);
|
|
||||||
}
|
|
||||||
~OGLPipeline() {
|
~OGLPipeline() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
OGLPipeline& operator=(OGLPipeline&& o) {
|
OGLPipeline& operator=(OGLPipeline&& o) noexcept {
|
||||||
handle = std::exchange<GLuint>(o.handle, 0);
|
handle = std::exchange<GLuint>(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -199,13 +198,13 @@ class OGLBuffer : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLBuffer() = default;
|
OGLBuffer() = default;
|
||||||
|
|
||||||
OGLBuffer(OGLBuffer&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLBuffer(OGLBuffer&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLBuffer() {
|
~OGLBuffer() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLBuffer& operator=(OGLBuffer&& o) {
|
OGLBuffer& operator=(OGLBuffer&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -234,12 +233,12 @@ class OGLSync : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLSync() = default;
|
OGLSync() = default;
|
||||||
|
|
||||||
OGLSync(OGLSync&& o) : handle(std::exchange(o.handle, nullptr)) {}
|
OGLSync(OGLSync&& o) noexcept : handle(std::exchange(o.handle, nullptr)) {}
|
||||||
|
|
||||||
~OGLSync() {
|
~OGLSync() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
OGLSync& operator=(OGLSync&& o) {
|
OGLSync& operator=(OGLSync&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, nullptr);
|
handle = std::exchange(o.handle, nullptr);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -267,13 +266,13 @@ class OGLVertexArray : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLVertexArray() = default;
|
OGLVertexArray() = default;
|
||||||
|
|
||||||
OGLVertexArray(OGLVertexArray&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLVertexArray(OGLVertexArray&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLVertexArray() {
|
~OGLVertexArray() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLVertexArray& operator=(OGLVertexArray&& o) {
|
OGLVertexArray& operator=(OGLVertexArray&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -302,13 +301,13 @@ class OGLFramebuffer : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
OGLFramebuffer() = default;
|
OGLFramebuffer() = default;
|
||||||
|
|
||||||
OGLFramebuffer(OGLFramebuffer&& o) : handle(std::exchange(o.handle, 0)) {}
|
OGLFramebuffer(OGLFramebuffer&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
|
||||||
|
|
||||||
~OGLFramebuffer() {
|
~OGLFramebuffer() {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLFramebuffer& operator=(OGLFramebuffer&& o) {
|
OGLFramebuffer& operator=(OGLFramebuffer&& o) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(o.handle, 0);
|
handle = std::exchange(o.handle, 0);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
Loading…
Reference in a new issue