Browse Source

Proper noexcept move constructor for Mesh.

Also documented the inability to copy.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
a168d2af4e
  1. 32
      src/Mesh.cpp
  2. 13
      src/Mesh.h

32
src/Mesh.cpp

@ -75,7 +75,7 @@ Mesh::~Mesh() {
(this->*destroyImplementation)();
}
Mesh::Mesh(Mesh&& other): _id(other._id), _primitive(other._primitive), _vertexCount(other._vertexCount), _indexCount(other._indexCount)
Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _vertexCount(other._vertexCount), _indexCount(other._indexCount)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(other._indexStart), _indexEnd(other._indexEnd)
#endif
@ -90,30 +90,26 @@ Mesh::Mesh(Mesh&& other): _id(other._id), _primitive(other._primitive), _vertexC
other._id = 0;
}
Mesh& Mesh::operator=(Mesh&& other) {
(this->*destroyImplementation)();
_id = other._id;
_primitive = other._primitive;
_vertexCount = other._vertexCount;
_indexCount = other._indexCount;
Mesh& Mesh::operator=(Mesh&& other) noexcept {
std::swap(_id, other._id);
std::swap(_primitive, other._primitive);
std::swap(_vertexCount, other._vertexCount);
std::swap(_indexCount, other._indexCount);
#ifndef MAGNUM_TARGET_GLES2
_indexStart = other._indexStart;
_indexEnd = other._indexEnd;
std::swap(_indexStart, other._indexStart);
std::swap(_indexEnd, other._indexEnd);
#endif
_indexOffset = other._indexOffset;
_indexType = other._indexType;
_indexBuffer = other._indexBuffer;
_attributes = std::move(other._attributes);
std::swap(_indexOffset, other._indexOffset);
std::swap(_indexType, other._indexType);
std::swap(_indexBuffer, other._indexBuffer);
std::swap(_attributes, other._attributes);
#ifndef MAGNUM_TARGET_GLES2
_integerAttributes = std::move(other._integerAttributes);
std::swap(_integerAttributes, other._integerAttributes);
#ifndef MAGNUM_TARGET_GLES
_longAttributes = std::move(other._longAttributes);
std::swap(_longAttributes, other._longAttributes);
#endif
#endif
other._id = 0;
return *this;
}

13
src/Mesh.h

@ -242,9 +242,6 @@ class MAGNUM_EXPORT Mesh {
friend class Context;
friend class MeshView;
Mesh(const Mesh&) = delete;
Mesh& operator=(const Mesh&) = delete;
public:
/**
* @brief Primitive type
@ -353,8 +350,11 @@ class MAGNUM_EXPORT Mesh {
*/
explicit Mesh(Primitive primitive = Primitive::Triangles);
/** @brief Copying is not allowed */
Mesh(const Mesh&) = delete;
/** @brief Move constructor */
Mesh(Mesh&& other);
Mesh(Mesh&& other) noexcept;
/**
* @brief Destructor
@ -364,8 +364,11 @@ class MAGNUM_EXPORT Mesh {
*/
~Mesh();
/** @brief Copying is not allowed */
Mesh& operator=(const Mesh&) = delete;
/** @brief Move assignment */
Mesh& operator=(Mesh&& other);
Mesh& operator=(Mesh&& other) noexcept;
/**
* @brief Index size

Loading…
Cancel
Save