Core/Stack[Array|Vector]: Are now default-initializable and movable
This commit is contained in:
parent
5fce345b3e
commit
31e6bfe43a
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -40,8 +40,11 @@ namespace Nz
|
|||
using reverse_iterator = std::reverse_iterator<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<T> m_ptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ namespace Nz
|
|||
* \class Nz::StackArray
|
||||
* \brief Core class that represents a stack-allocated (if alloca is present) array
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
StackArray<T>::StackArray() :
|
||||
m_size(0),
|
||||
m_ptr(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
StackArray<T>::StackArray(T* stackMemory, std::size_t size) :
|
||||
m_size(size),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_STACKVECTOR_HPP
|
||||
|
||||
#include <Nazara/Core/MemoryHelper.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
|
||||
#ifdef NAZARA_ALLOCA_SUPPORT
|
||||
#define NazaraStackVector(T, capacity) Nz::StackVector<T>(static_cast<T*>(NAZARA_ALLOCA((capacity) * sizeof(T))), capacity)
|
||||
|
|
@ -37,7 +38,10 @@ namespace Nz
|
|||
using reverse_iterator = std::reverse_iterator<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<T> m_ptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<typename T>
|
||||
StackVector<T>::StackVector() :
|
||||
m_capacity(0),
|
||||
m_size(0),
|
||||
m_ptr(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
StackVector<T>::StackVector(T* stackMemory, std::size_t capacity) :
|
||||
m_capacity(capacity),
|
||||
|
|
|
|||
Loading…
Reference in New Issue