diff --git a/ChangeLog.md b/ChangeLog.md index f5a1edf45..79425fab0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -169,7 +169,7 @@ Nazara Engine: - Fixed TileMap not rendering the right materials if it had no tile using some materials in-between - Added Vector[2|3|4](u)i64 typedefs - Fixed missing static Vector4::DotProduct implementation -- ⚠ **By default, Nazara computes the mass center of all 2D physics object when calling SetGeom** +- ⚠ **By default, Nazara now computes the mass center of all 2D physics object when calling SetGeom** - ⚠ Added Collider2D::ComputeCenterOfMass - Signal now implement a copy constructor and copy assignation operator for convenience - Fixed ENet UnreliableFragment packets sent as Unreliable (and such being incomplete upon reception) @@ -193,6 +193,8 @@ Nazara Engine: - Added SimpleTextDrawer::[Get|Set]MaxLineWidth (which does line wrap) - TypeTag helper struct now includes a Type using - GuillotineBinPack::Insert overload taking multiple rectangles no longer does a heap allocation +- StackArray and StackVector now have a default constructor initializing them with no size/capacity +- StackArray and StackVector are now movable Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Core/StackArray.hpp b/include/Nazara/Core/StackArray.hpp index 1bed2b16c..bf58f1a46 100644 --- a/include/Nazara/Core/StackArray.hpp +++ b/include/Nazara/Core/StackArray.hpp @@ -40,8 +40,11 @@ namespace Nz using reverse_iterator = std::reverse_iterator; using size_type = std::size_t; + StackArray(); StackArray(T* stackMemory, std::size_t size); StackArray(T* stackMemory, std::size_t size, NoInitTag); + StackArray(const StackArray&) = delete; + StackArray(StackArray&&) = default; ~StackArray(); reference back(); @@ -81,9 +84,12 @@ namespace Nz reference operator[](size_type pos); const_reference operator[](size_type pos) const; + StackArray& operator=(const StackArray&) = delete; + StackArray& operator=(StackArray&&) = default; + private: std::size_t m_size; - T* m_ptr; + MovablePtr m_ptr; }; } diff --git a/include/Nazara/Core/StackArray.inl b/include/Nazara/Core/StackArray.inl index 989ffdf88..7e46afc64 100644 --- a/include/Nazara/Core/StackArray.inl +++ b/include/Nazara/Core/StackArray.inl @@ -24,6 +24,14 @@ namespace Nz * \class Nz::StackArray * \brief Core class that represents a stack-allocated (if alloca is present) array */ + + template + StackArray::StackArray() : + m_size(0), + m_ptr(nullptr) + { + } + template StackArray::StackArray(T* stackMemory, std::size_t size) : m_size(size), diff --git a/include/Nazara/Core/StackVector.hpp b/include/Nazara/Core/StackVector.hpp index 18d7e7437..6d01d8589 100644 --- a/include/Nazara/Core/StackVector.hpp +++ b/include/Nazara/Core/StackVector.hpp @@ -8,6 +8,7 @@ #define NAZARA_STACKVECTOR_HPP #include +#include #ifdef NAZARA_ALLOCA_SUPPORT #define NazaraStackVector(T, capacity) Nz::StackVector(static_cast(NAZARA_ALLOCA((capacity) * sizeof(T))), capacity) @@ -37,7 +38,10 @@ namespace Nz using reverse_iterator = std::reverse_iterator; using size_type = std::size_t; + StackVector(); StackVector(T* stackMemory, std::size_t capacity); + StackVector(const StackVector&) = delete; + StackVector(StackVector&&) = default; ~StackVector(); reference back(); @@ -99,10 +103,13 @@ namespace Nz reference operator[](size_type pos); const_reference operator[](size_type pos) const; + StackVector& operator=(const StackVector&) = delete; + StackVector& operator=(StackVector&&) = default; + private: std::size_t m_capacity; std::size_t m_size; - T* m_ptr; + MovablePtr m_ptr; }; } diff --git a/include/Nazara/Core/StackVector.inl b/include/Nazara/Core/StackVector.inl index 72c51afc2..580ade499 100644 --- a/include/Nazara/Core/StackVector.inl +++ b/include/Nazara/Core/StackVector.inl @@ -24,6 +24,14 @@ namespace Nz * \class Nz::StackVector * \brief Core class that represents a stack-allocated (if alloca is present) vector, that is with a capacity different from its size */ + template + StackVector::StackVector() : + m_capacity(0), + m_size(0), + m_ptr(nullptr) + { + } + template StackVector::StackVector(T* stackMemory, std::size_t capacity) : m_capacity(capacity),