diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index 0e4ed3b7c..eec23149c 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -25,12 +25,12 @@ class NzSparsePtr void Set(void* ptr); void SetStride(unsigned int stride); - T& operator*(); - T& operator->(); - T& operator[](unsigned int index); + T& operator*() const; + T& operator->() const; + T& operator[](unsigned int index) const; - NzSparsePtr operator+(unsigned int count); - NzSparsePtr operator-(unsigned int count); + NzSparsePtr operator+(unsigned int count) const; + NzSparsePtr operator-(unsigned int count) const; NzSparsePtr& operator+=(unsigned int count); NzSparsePtr& operator-=(unsigned int count); diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index 73bdee917..f769e577e 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -43,31 +43,31 @@ void NzSparsePtr::SetStride(unsigned int stride) } template -T& NzSparsePtr::operator*() +T& NzSparsePtr::operator*() const { return *reinterpret_cast(m_ptr); } template -T& NzSparsePtr::operator->() +T& NzSparsePtr::operator->() const { return *reinterpret_cast(m_ptr); } template -T& NzSparsePtr::operator[](unsigned int index) +T& NzSparsePtr::operator[](unsigned int index) const { return *reinterpret_cast(m_ptr + index*m_stride); } template -NzSparsePtr NzSparsePtr::operator+(unsigned int count) +NzSparsePtr NzSparsePtr::operator+(unsigned int count) const { return NzSparsePtr(m_ptr + count*m_stride, m_stride); } template -NzSparsePtr NzSparsePtr::operator-(unsigned int count) +NzSparsePtr NzSparsePtr::operator-(unsigned int count) const { return NzSparsePtr(m_ptr - count*m_stride, m_stride); } @@ -96,9 +96,13 @@ NzSparsePtr& NzSparsePtr::operator++() template NzSparsePtr NzSparsePtr::operator++(int) { + // On fait une copie de l'objet NzSparsePtr tmp(*this); + + // On modifie l'objet operator++(); + // On retourne la copie return tmp; } @@ -112,9 +116,13 @@ NzSparsePtr& NzSparsePtr::operator--() template NzSparsePtr NzSparsePtr::operator--(int) { + // On fait une copie de l'objet NzSparsePtr tmp(*this); + + // On modifie l'objet operator--(); + // On retourne la copie return tmp; } @@ -154,5 +162,4 @@ bool NzSparsePtr::operator>=(const NzSparsePtr& ptr) const return m_ptr >= ptr.m_ptr; } - #include